while is not setting $_ for you. in
Try this instead:while (<PINGALLIP>) { if (/is alive/) { chomp; print ALIVEIP $_; } }
If the match is true then print $_ for all lines. I omitted chomp since the record delimiters will probably be handy in the file./is alive/ and print ALIVEIP for <PINGALLIP>;
After Compline,
Zaxo
In reply to Re: Printing matched lines
by Zaxo
in thread Printing matched lines
by zuinc
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |