in reply to Re: match substitution
in thread match substitution

Actually, it produces
\1 better written as $1 at a.pl line 3. \2 better written as $2 at a.pl line 3. 725_275 is an entry - and will be at 423_569 -but- not at 012_457.
if you don't disable warnings. \1 and \2 are not a valid Perl variables.

Replies are listed 'Best First'.
Re^3: match substitution
by umasuresh (Hermit) on Jan 27, 2010 at 01:05 UTC
    Thanks for pointing it out. You are right, I get the same when I turn the warnings on!
    UPDATE:
    use strict; use warnings; #use utf8; my $str = "725-275 is an entry - and will be at 423-569 -but- not at 0 +12-457."; print "before: $str\n"; $str =~ s/([0-9]{3})-([0-9]{3})/$1\x{2014}$2/g; print "after: $str\n" produces: before: 725-275 is an entry - and will be at 423-569 -but- not at 012- +457. after: 725—275 is an entry - and will be at 423—569 -but- not at 012—4 +57.
      Wow! Thanks!