M
Mark
use strict ;
use warnings ;
my $txt = 'abc Start something' ;
my $startpoint = index($txt,'Start') ;
die "Start point not found" if $startpoint < 0 ;
$_ = $txt ;
pos = $startpoint ;
if (/\G(.*)/g) {
print "matched=$1\n" ; # prints "matched=Start something"
}
else {
print "no match\n" ; }
pos = $startpoint ;
if ($txt =~ /\G(.*)/g) {
print "matched=$1\n" ; # prints "matched=abc Start something"
}
else {
print "no match\n" ;
}
I expected the matched part in both cases to be the same. The second
case doesn't seem to honor the value of pos.
Can someone please explain.
use warnings ;
my $txt = 'abc Start something' ;
my $startpoint = index($txt,'Start') ;
die "Start point not found" if $startpoint < 0 ;
$_ = $txt ;
pos = $startpoint ;
if (/\G(.*)/g) {
print "matched=$1\n" ; # prints "matched=Start something"
}
else {
print "no match\n" ; }
pos = $startpoint ;
if ($txt =~ /\G(.*)/g) {
print "matched=$1\n" ; # prints "matched=abc Start something"
}
else {
print "no match\n" ;
}
I expected the matched part in both cases to be the same. The second
case doesn't seem to honor the value of pos.
Can someone please explain.