in reply to In-place editing of files (was: general perl question)
You want to use the -i and -p options. Do a perldoc perlrun for a complete list of Perl options.
Your script should look like:
#!/bin/perl -w -i .bak -p s/foo/toto/g; s/^\s*//;
This will do the substitution on each line of the file(s) passed as arguments and save the original files with a .bak suffix.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: general perl question
by Rosencrantz (Initiate) on Apr 25, 2001 at 00:22 UTC |