This is the documented behaviour. Add the /c flag to the second match to keep the position even after the failed match. See perlre for details.#!/usr/bin/perl use strict; use warnings; my $s = << '__STRING__'; hubba1 bubba hubba2 __STRING__ $s =~ /bubba/gm; $s =~ /no match/gm; print $s =~ /(hubba\d)/gm;
In reply to Re: Matching with /g: Is this a bug?
by choroba
in thread Matching with /g: Is this a bug?
by morgon
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |