in reply to Re: Trying to substitute a variable with another variable in a string but not working
in thread Trying to substitute a variable with another variable in a string but not working
Perl is supposed to make easy things easy and in place file editing should be easy shouldn't it? Consider:
use strict; use warnings; my $cell_name = 'xyzzy'; my $match = 'STARTING_PATTERN'; @ARGV = 'delme.txt'; $^I = '.bak'; while (<>) { s/$1/$cell_name/ if /$match\s+(.*)/; print; }
Yup, that looks easy.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Trying to substitute a variable with another variable in a string but not working
by RonW (Parson) on Feb 25, 2015 at 00:06 UTC | |
|
Re^3: Trying to substitute a variable with another variable in a string but not working
by Anonymous Monk on Feb 24, 2015 at 23:23 UTC |