yitzle wrote:
> Take a look at the grep function
> http://perldoc.perl.org/functions/grep.html
>
> Also of potential use is the qr// quote operator:
> http://perldoc.perl.org/perlop.html#Regexp-Quote-Like-Operators
>
> This lets you do:
>
> my $ip_search = qr/$ip_string/;
> my @lines_with_ip = grep /$ip_search/, @raw_data; # or is that grep
> $ip_search, @raw_data; ?
>   
He's looking for the lines that don't have the IP addresses so it would be

my @lines_without_ip = grep !/$ip_search/, @raw_data;

Using this method you could iterate through all of the IP's you want
removed, something along the lines of...

my @newdata = <FH>;
my @ips_to_remove = ("192.168.0.0", "192.168.0.255");

foreach my $ip (@ips_to_remove) {
    @newdata = grep !/$ip/, @newdata;
}

Then output the resulting array into a new file.

> Now you got an array with only lines that got the ip.
>
> my $i = 0;
> foreach @lines_with_ip {
>   print $_;
>   $i++;
> }
> print "The IP was found $i times\n";
>
>   




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to