
On 12/6/05, Eric Niebler <eric@boost-consulting.com> wrote:
Boris Kolpackov wrote:
John,
"John Maddock" <john@johnmaddock.co.uk> writes:
Following the logic above it will match all single letters in the string, no?
No, because of the trailing $.
The original expression had trailing $ as well but it didn't help much, did it?
So what's the verdict, is this a bug or a feature?
Feature. Perl has the same behavior:
$str = 'test.cidl'; $str =~ s/(\.(idl|cidl|cdl))?$/E.idl/g; print "$str\n";
... prints:
testE.idlE.idl
Indeed it does. If the user wants only one substitution, I'd say the use of /g, which allows s/// to match multiple times, is the central mistake. ** With /g $ perl -le '($a = "test.cidl") =~ s/(\.(c?idl|cdl))?$/E.idl/g; print $a' testE.idlE.idl ** Without $ perl -le '($a = "test.cidl") =~ s/(\.(c?idl|cdl))?$/E.idl/; print $a' testE.idl -- Caleb Epstein caleb dot epstein at gmail dot com