in reply to Piping many individual files into a single perl script
As an alternative to iterating over @ARGV and opening each file yourself, you could use a combination of <> and $ARGV:
my %total; my %by_file; while (<>) { chomp; $total{$_}++; $by_file{$ARGV}{$_}++; }
A simple output routine:
my @strings = sort keys %total; for my $string ( @strings ) { print( "\t$string" ); } print( "\n" ); for my $file ( keys %counts ) { print( $file ); for my $string ( @strings ) { print( "\t$by_file{$file}{$string}" ); } print( "\n" ); }
The file names are passed to the script in same fashion as in my first post.
|
|---|