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
>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
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,
>
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 <
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
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;
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