#match multiple occurrences of pattern
use strict;
my $text=<<"_end";
a multiple line text
the second line
the last line
_end
print "input:\n$text\n";
#match one at a time
print "output words:\n";
while($text =~ /\w+/g) {
print "$&\n";
}
#match multiple occurances of pattern
use strict;
my $text=<<"_end";
a multiple line text
the second line
the last line
_end
print "input:\n$text\n";
#return all matchs
print "output words:\n";
my @allwords=$text =~ /\w+/g;
print join("\n", @allwords), "\n";