use strict;
$_="this that other thing that thw tests sometimes";
my $regex = qr/(t..)\w+\s+?(\w\w)(.+)/;
my @buffer;
my @x;
while ( (@x[0..1],$_) = /$regex/) {
push @buffer, [ @x ];
print join(",",@x) . ";\n";
}
Changes:
- You need to know how many elements to expect
- The regex has been modified to return all remaining information as the final element
- The final element gets re-stored into $_
- No more /g modifier
"As you get older three things happen. The first is your memory goes, and I can't remember the other two... "
- Sir Norman Wisdom
|