in reply to substitution with regex
Other monks have given good solutions, but you might also be want to know what your mistakes are.
First, you can't use the $1 and $2 special variables in a formula before they have been set by a regular expression. In other word, they are undefined at the point where you're using them in the conversion formula.
Second, I am not sure why you enclose them within curly braces then is no need to do that. If you want to isolate them from neighboring characters (not needed here), then the proper syntax is ${1}, not {$1}.
Finally, it seems from the error messages you get that your input file is not properly opened. When you open a file, you should always check if the statement worked:
Update: fixed a typo on the filename on the preceding line. Thanks, soonix.open IN,'<',"part2.txt" or die "could not open file part2.txt $!";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: substitution with regex
by soonix (Chancellor) on Jan 19, 2018 at 12:46 UTC | |
by Laurent_R (Canon) on Jan 19, 2018 at 17:52 UTC |