6 Replies - 814 Views - Last Post: 27 October 2015 - 05:57 AM

#1 Yya09  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 19
  • Joined: 22-October 15

Perl question

Posted 27 October 2015 - 02:13 AM

HI everyone i am trying to control a while loop in Perl, i want to terminated the loop when the repition of the loop reaches 3000 time, i am trying to create a script that generate a wordlist file that contian 3000 lines . and here is my code :

open my $file, ">>", "file.txt" or die "couldn't open the file

while($max < 10){

print $file "you are the one\n";
 
} 

close($file);#the end of the file (file.txt)




so how can i do it?

Is This A Good Question/Topic? 0
  • +

Replies To: Perl question

#2 ndc85430  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 611
  • View blog
  • Posts: 2,578
  • Joined: 13-June 14

Re: Perl question

Posted 27 October 2015 - 05:11 AM

Surely you want to increment $max in the loop?
Was This Post Helpful? 0
  • +
  • -

#3 Yya09  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 19
  • Joined: 22-October 15

Re: Perl question

Posted 27 October 2015 - 05:19 AM

Ok thanks , but where should i put the increment

Sorry i miss understand , i want to generate a wordlist file that contians 3000 lines , so i want to stop the loop when the repition of the loop become 3000 lines
Was This Post Helpful? 0
  • +
  • -

#4 ndc85430  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 611
  • View blog
  • Posts: 2,578
  • Joined: 13-June 14

Re: Perl question

Posted 27 October 2015 - 05:21 AM

Well, have a think about what your code is doing. Right now, how many iterations of the loop are going to happen? Or, to put it another way: when will your loop terminate right now?

This post has been edited by ndc85430: 27 October 2015 - 05:21 AM

Was This Post Helpful? 0
  • +
  • -

#5 Yya09  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 19
  • Joined: 22-October 15

Re: Perl question

Posted 27 October 2015 - 05:46 AM

that is what i am seeking , i need to make a termination piont .
Was This Post Helpful? 0
  • +
  • -

#6 andrewsw  Icon User is offline

  • say what now
  • member icon

Reputation: 6403
  • View blog
  • Posts: 25,878
  • Joined: 12-December 12

Re: Perl question

Posted 27 October 2015 - 05:51 AM

Work through some simple examples until you understand the while loop. E.g.

Perl while Loop

There are other loops though.

This post has been edited by andrewsw: 27 October 2015 - 05:52 AM

Was This Post Helpful? 0
  • +
  • -

#7 Yya09  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 19
  • Joined: 22-October 15

Re: Perl question

Posted 27 October 2015 - 05:57 AM

ok and thanks ,andrewsw
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1