|
|
| go ahead... be a heretic | |
| PerlMonks |
Use Perl's in-place file-handling capabilitiesby petdance (Parson) |
| on Sep 28, 2001 at 16:32 UTC ( [id://115429]=note: print w/replies, xml ) | Need Help?? |
This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.
For one, you don't need both of those patterns at the top,
if you just replace
with
Second, I'd look at letting Perl's -i and -p flags do all your editing in place for you. It takes care of all the globbing, the reading the file, etc etc etc. For instance, your code could simply be (rough and untested): And you'd just call it as:
Perl has some very powerful, very common idioms to do this most common of text transformations. Take advantage of them when you can.
xoxo,
In Section
Seekers of Perl Wisdom
|
|
||||||||||||||||||||||||||||