in reply to Run a variable as a line of code?
Not answering your immediate question, but a Perl idiom worth knowing is the edit inplace:
@ARGV = @files; $^I = '.bak'; while (<>) { # do something with each line of each file # The original line contents is in $_ # print prints to the new version of the file s/foo/bar/g; print; }
Update: Fix @ARGV - thanks QM :)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Run a variable as a line of code?
by QM (Parson) on Apr 03, 2006 at 22:28 UTC | |
|
Re^2: Run a variable as a line of code?
by lev36 (Sexton) on Apr 06, 2006 at 17:53 UTC | |
by GrandFather (Saint) on Apr 06, 2006 at 19:26 UTC |