my $pat = qr{ .*(.*)<\/author>.*(.*)<\/text }xs; #### my $pat = qr{ .*?(.*?)<\/author>.*?(.*?)<\/text }xs; #### while ($data =~ m/$pat/gc) { my ($auth, $text) = ($1, $2); for( $text ) { s/[ ]+/ /g; s/^\s+//; s/\s+$//; } printf "%s: %s\n\n" , $auth , $text; }