in reply to new line every match

#!/usr/bin/perl -w use strict; my $str = "address 6433 main st address 6434 main st address 6435 main + st "; # grep gets rid of the "" at the beginning. # performace is slow, but effective # there is more than one way to do this # no fancy regex is required my (@addresses) = grep{$_}split /address\s*/, $str; my $line=1; foreach (@addresses) { print "address ", $line++, " $_\n"; } __END__ address 1 6433 main st address 2 6434 main st address 3 6435 main st