Anyone know why these print different things?
Why does adding an end-of-line assertion on the second regexp cause it to be less greedy?
#!/usr/bin/perl -w
use strict;
my $str1 = ' foobar ';
$str1 =~ s/^\s*(.*?)\s*/$1/;
print $str1 . "#\n";
my $str2 = ' foobar ';
$str2 =~ s/^\s*(.*?)\s*$/$1/;
print $str2 . "#\n";
Why does adding an end-of-line assertion on the second regexp cause it to be less greedy?
#!/usr/bin/perl -w
use strict;
my $str1 = ' foobar ';
$str1 =~ s/^\s*(.*?)\s*/$1/;
print $str1 . "#\n";
my $str2 = ' foobar ';
$str2 =~ s/^\s*(.*?)\s*$/$1/;
print $str2 . "#\n";