Hey Monks,
I have the following code:
my $ip = qr/\b192.168.3.5\b/;
my $line = 0;
my @fwlog;
my $logfile = "/tmp/05jul01.drop";
open LOG, "$logfile" or die "Can't open $logfile: $!\n";
while ($line=<LOG>){
chomp($line);
while($line =~ $ip) {
print "$line\n";
#push (@fwlog,$line);
}
}
close LOG;
#print "@fwlog\n";
This works if I just print
$line in the loop, but I want to save the results of
$line to a variable so that I can use it outside of the while loop. As you can see, I tried a few different things with push, but that did not work. What is the best way of accomplishing this?
Thanks,
Dru
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.