When using the diamond operator to iterate over all the files in @ARGV, I'd like to be able to send the output from each file to a separate place rather than all together. Is the following code the only way to do this? It seems that there would be a way around checking to see if the filename in $ARGV has changed on every single line of input?
Thanks,
Dana
#!/usr/bin/perl -w
use strict;
my $oldarg;
while (<>){
if ($ARGV ne $oldarg){
my $outputfile="out".$ARGV;
open OUTPUT,">", $outputfile;
$oldarg=$ARGV;
}
print OUTPUT "$_";
}