Ron McKeever wrote:
> I wanted to print if it matches my range of IP's. I thought I could use the
> (#..#) and it would work, but it didn't:
>
> #!/usr/bin/perl -nlw
>
> # Print if Ip's are in
> # 111.9.1-18.### or
> # 111.9.20-100.###
> # range
> #
> my $a="1-18";
> my $b="20-100";
>
> while (<>)
You are using the -n switch so you are already inside of a while loop!
> {
> chomp $_;
You are using the -l switch so the contents of $_ have already been chomp()ed!
> next if ($_ eq "");
>
> my ( $number,$ip,$host ) = split(/,/,$_);
> if ( $ip =~ /111.9.\b(1..18)\b.\d/){
UNTESTED.
if ( $ip =~
/\b111\.9\.(?:[1-9]|1[0-8]|[2-9]\d|100)\.(?:\d?\d|1\d\d|2[0-4]\d|25[0-5])\b/ ) {
> print "$ip";
> }
> }
> exit;
John
--
use Perl;
program
fulfillment
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>