$string = ""; while ($string =~ m/(.*)<\/name>/g) { print "$1, $2\n"; }