when running in script with system command
What do you mean by this - are you running system("perl ... from inside a Perl script? That's not necessary, and a bit wasteful. How to best integrate the two depends on how you are further processing the files, so if you could explain and show an SSCCE, we could help you better.
One way to do the same thing as the oneliner I posted above without calling another Perl process would be:
{ # new scope for local
local *ARGV; @ARGV = @files;
local $^I = ""; # -i command line switch
while (<>) {
print $_;
print "\n" if $. % 4 == 0;
close ARGV if eof;
}
}
However, if you plan on further processing the files in the same script, this will be inefficient!
Update: Fixed typo
Update 2: Fixed this potential issue in the above example code. |