Mega Code Archive

 
Categories / Perl / Regular Expression
 

Iterate over matches with while and $1

#!/usr/bin/perl use warnings; use strict; my $text = "one, two, three, four"; while ($text =~ /\b(\w+)\b/g) {     print $1, "\n"; }