|
Posted by Mark on May 13, 2008, 5:43 pm
Please log in for more thread options > use strict ;
> use warnings ;
>
> my $txt =3D 'abc Start something' ;
> my $startpoint =3D index($txt,'Start') ;
> die "Start point not found" if $startpoint < 0 ;
>
> $_ =3D $txt ;
>
> pos =3D $startpoint ;
> if (/\G(.*)/g) {
> =A0 =A0 print "matched=3D$1\n" ; # prints "matched=3DStart something"}
>
> else {
> =A0 =A0 print "no match\n" ; }
>
> pos =3D $startpoint ;
> if ($txt =3D~ /\G(.*)/g) {
> =A0 =A0 print "matched=3D$1\n" ; # prints "matched=3Dabc Start something"
>
> }
>
> else {
> =A0 =A0 print "no match\n" ;
>
> }
>
> I expected the matched part in both cases to be the same. =A0The second
> case doesn't seem to honor the value of pos.
>
> Can someone please explain.
Thank you to all that responded.
|