A
Anthony Roy
Hi all,
I have just come accross this little problem:
I am trying to pass in the find and replace values for a regex
substitution via the command lin, but I am not getting the expexted
result at all.
The perl program (attached) is:
------------------------------------
$in = shift;
$out = shift;
$string = shift;
$string =~ s/$in/$out/;
print $string;
------------------------------------
The command line used to call the script is:
perl rename.pl (\w+).old $1 abcd.old
I had expected the output to be: abcd
instead it gives: $1
Replacing the line "$string =~ s/$in/$out/;" with "$string =~
s/$in/$1/;" works as expected.
I presume that the $out is being expanded to $1, but the $1 is not then
being expanded itself.
Any idea how to get this to work as it should?
Thanks.
I have just come accross this little problem:
I am trying to pass in the find and replace values for a regex
substitution via the command lin, but I am not getting the expexted
result at all.
The perl program (attached) is:
------------------------------------
$in = shift;
$out = shift;
$string = shift;
$string =~ s/$in/$out/;
print $string;
------------------------------------
The command line used to call the script is:
perl rename.pl (\w+).old $1 abcd.old
I had expected the output to be: abcd
instead it gives: $1
Replacing the line "$string =~ s/$in/$out/;" with "$string =~
s/$in/$1/;" works as expected.
I presume that the $out is being expanded to $1, but the $1 is not then
being expanded itself.
Any idea how to get this to work as it should?
Thanks.