in reply to new line every match
You might want to put your sample data into <code> tags, like your code, so we can tell for sure how it is formatted. But it appears that all your addresses are on a single line, and you want to break them into multiple lines. If that's the case, then <INFILE> will read in an entire line containing many addresses. That should match your regex (once), so the line should be split on spaces into words, and each word printed on its own line. What do you mean by "somehow it is not printing this part"? What is it printing?
Incidentally, there's no point in looping on $_ and then assigning it to a variable inside your loop, and it could (theoretically, at least) cause a bug. So don't do this:
while(<INFILE>){ my $line = $_; # do stuff with $line # but do one of these instead while(<INFILE>){ # do stuff with $_ # or while(my $line = <INFILE>){ # do stuff with $line
(Is there a popular Perl book or tutorial that shows that method? Seems like it shows up a lot here lately.)
Aaron B.
Available for small or large Perl jobs; see my home node.
|
|---|