in reply to "ee" in Regular Expression: version issue?
Try concatenating the vars for use in the substitution:
use strict; use warnings; my $lhs = '(\d*?)-(.*?)-(.*)'; my $rhs = '$1.$2.$3'; while ( my $var = <DATA> ) { chomp $var; $var =~ s/$lhs/$rhs/ee; print $var, "\n"; } __DATA__ 123-456-789 -456-789 789
Output:
123456789 456789 789
From the error message, it appears that the results of the first evaluation is ambiguous to the interpreter when it attempts to evaluate it without the concatenation operator.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: "ee" in Regular Expression: version issue?
by kennethk (Abbot) on Dec 03, 2012 at 20:23 UTC | |
by Kenosis (Priest) on Dec 03, 2012 at 20:32 UTC |