They have all been helpful.
Thanks,
On Oct 17, 2007, at 4:40 PM, Matthew Whipple wrote:
Matthew Whipple wrote:
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;
}
I was debating whether to even send that last but but it seemed to
serve
some purpose or other to me (an association with on the fly command
line
grep)...but it would probably be faster to type and to run if rather
than creating an array you just stuck with the single test and entered
the IP addresses into a "|" delimited scalar (i.e
"192.168.0.0|192.168.0.255").
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/