Re: printing a range of ip addresses

2006-03-22 Thread John W. Krahn
Harold Castro wrote: > Hi, Hello, > Can you tell me why this loop doesn't work??? > > #!/usr/local/bin/perl > use warnings; > use strict; > > our $hostpart = 1; > our $networkpart = 128; > $|=1; > >while ($networkpart <= 158){ > while ($hostpart <= 256){ > print "20

RE: printing a range of ip addresses

2006-03-22 Thread Jeff Pang
>How about > >#!/usr/bin/perl -w > >use strict; >use warnings; > >for( my $networkpart = 128; $networkpart <= 158; $networkpart++ ){ > for( my $hostpart = 0; $hostpart < 256; $hostpart++ ){ >print "202.90.$networkpart.$hostpart\n"; > } >} >__END__ > The '-w' option is not needed here since

Re: printing a range of ip addresses

2006-03-22 Thread nishanth ev
Edit your loop like this while ($networkpart <= 158){ while ($hostpart <= 256){ print "202.90.".$networkpart.".".$hostpart, "\n"; $hostpart++; } # #Change the $hostpart back to 0 # $hostpart=0; $networkpart++; } --- Harold Castro <[EMAIL PROTECTED]> wrote: > Hi, >

RE: printing a range of ip addresses

2006-03-22 Thread Thomas Bätzler
Hi, Harold Castro <[EMAIL PROTECTED]> asked: > Can you tell me why this loop doesn't work??? > > #!/usr/local/bin/perl > use warnings; > use strict; > > our $hostpart = 1; > our $networkpart = 128; That should probably be "my" instead of "our". > $|=1; > >while ($networkpart <

RE: printing a range of ip addresses

2006-03-22 Thread balan.ranganathan
I am seeing code optimization done inside the while loop. Thanks Best regards Bala -Original Message- From: Harold Castro [mailto:[EMAIL PROTECTED] Sent: Wednesday, March 22, 2006 2:50 PM To: beginners@perl.org Subject: printing a range of ip addresses Hi, Can you tell me why this

Re: printing a range of ip addresses

2006-03-22 Thread Alon Marx
Try setting the $hostpart to 1 just before the inner while loop :) On Wed, 2006-03-22 at 01:20 -0800, Harold Castro wrote: > Hi, > > Can you tell me why this loop doesn't work??? > > #!/usr/local/bin/perl > use warnings; > use strict; > > our $hostpart = 1; > our $networkpart = 128;

printing a range of ip addresses

2006-03-22 Thread Harold Castro
Hi, Can you tell me why this loop doesn't work??? #!/usr/local/bin/perl use warnings; use strict; our $hostpart = 1; our $networkpart = 128; $|=1; while ($networkpart <= 158){ while ($hostpart <= 256){ print "202.90.".$networkpart.".".$hostpart, "\n"; ++$hostpar