in reply to replacing text in multiple files
If you have (a version of) the unix/linux "cat" utility, you can use the "diamond" operator as suggested by Eliya's initial reply, and pipe the concatenated set of files to your script's STDIN -- for that matter, you can also just print to STDOUT, and use redirection to a file on the command line:
With that sort of usage, you don't need to worry about opening or closing files in your code; just read, do stuff, and print:cat *.log | your_script > modified.log-data
#!/usr/bin/perl use strict; while (<>) { # do stuff here, then... print; }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: replacing text in multiple files
by Eliya (Vicar) on Apr 14, 2012 at 04:43 UTC |
In Section
Seekers of Perl Wisdom