D
Dawn Schepleng
Hi
I am a novice Perl programmer, and have encountered the following problem.
I can make the following string substitution work:
$high_level_dir = "/ceswbl2/installed/bin"
$low_level_dir = "/ceswbl2/src/sparc/bin";
$line =~ s{$low_level_dir(/\w+)+/(\w+)}{$high_level_dir/$2};
This will correctly take a line like:
/ceswbl2/src/sparc/bin/cec_sim/radar/sps48/cecsimlm
and make substitutions such that $line then equals:
/ceswbl2/installed/bin/cecsimlm.
I'm using \w+ to represent a word with numbers and underscores, and am
using "(", ")", and "/" to be literal, and using the substitution format of
"s{}{}" vice "s///" to be more readable.
However, when I take this working perl substitution and try to invoke it as a
system call like:
system("perl -pi -e 's{$low_level_dir(/\w+)+/(\w+)}{$high_level_dir/$2}'
$real_run_file");
It no longer works. The error occurs in a first-pass parse of the perl script,
and says something line "Unrecognized escape \w passed through
in cepSetGoEnv.pl at line 31".
With the help of a co-worker, we've tried changing "{" "}" to "|" and we've
also tried escaping out the "(" and ")" with no luck.
What is the subtle detail that makes this work in-line, but not when the script
is run w/i the system call?
Any ideas would be appreciated!
Thanks,
Dawn Schepleng
JHU/APL
I am a novice Perl programmer, and have encountered the following problem.
I can make the following string substitution work:
$high_level_dir = "/ceswbl2/installed/bin"
$low_level_dir = "/ceswbl2/src/sparc/bin";
$line =~ s{$low_level_dir(/\w+)+/(\w+)}{$high_level_dir/$2};
This will correctly take a line like:
/ceswbl2/src/sparc/bin/cec_sim/radar/sps48/cecsimlm
and make substitutions such that $line then equals:
/ceswbl2/installed/bin/cecsimlm.
I'm using \w+ to represent a word with numbers and underscores, and am
using "(", ")", and "/" to be literal, and using the substitution format of
"s{}{}" vice "s///" to be more readable.
However, when I take this working perl substitution and try to invoke it as a
system call like:
system("perl -pi -e 's{$low_level_dir(/\w+)+/(\w+)}{$high_level_dir/$2}'
$real_run_file");
It no longer works. The error occurs in a first-pass parse of the perl script,
and says something line "Unrecognized escape \w passed through
in cepSetGoEnv.pl at line 31".
With the help of a co-worker, we've tried changing "{" "}" to "|" and we've
also tried escaping out the "(" and ")" with no luck.
What is the subtle detail that makes this work in-line, but not when the script
is run w/i the system call?
Any ideas would be appreciated!
Thanks,
Dawn Schepleng
JHU/APL