in reply to Re: new line every match
in thread new line every match

Did my reply here fail to meet your needs? I think I understood your question. Why are you repeating it?


Dave

Replies are listed 'Best First'.
Re^3: new line every match
by starface245 (Novice) on Jul 07, 2012 at 00:55 UTC
    Sorry Dave, but it did fail my needs. I needed someone to help fix my code, but not totally change it.

      Well, it's "just start over" broken, but if you want to keep it the way it is and just make it work with as few changes as possible, this should do:

      print "This is the list of address\n", "here are the addresses\n"; while (<INFILE>) { my($line) =$_; chomp($line); while ($line =~ /(address............)/g ) { my @values = split(' ', $line); foreach my $val (@values) { next; print "$val\n"; } print "$1\n"; } }

      You'll note I added two print statements, a next, changed an if( to a while(, and added a /g to your regex. The rest is untouched. If your input data is what you say it is in your original post (a single line of text containing multiple address fields), this works fine and lets you feel like the original code didn't change much.

      If it doesn't work, go back and verify that your input data looks exactly like what you posted in your original question.


      Dave