in reply to Writing a new file in Perl
There's a lot about this that could be improved, but here's your specific problem:
Your while loop grabs the text between "hops" and "Trace", which includes the whole output of a traceroute. The second line searches that for an IPv4 address, and if one is found, prints it. It only searches once, so only one will be found. To make it search repeatedly, you need to give it the 'g' modifier, and put it in a loop:while(/hops(.+)Trace/mg){ print $1, "\n" if /($RE{net}{IPv4})/;
print "$1\n" for /($RE{net}{IPv4})/g;
Aaron B.
Available for small or large Perl jobs; see my home node.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Writing a new file in Perl
by maheshkumar (Sexton) on Jul 07, 2012 at 20:36 UTC | |
by aaron_baugher (Curate) on Jul 07, 2012 at 22:35 UTC |