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.
In reply to Re: general perl question
by mirod
in thread In-place editing of files (was: general perl question)
by cghost23
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |