http://www.perlmonks.org?node_id=65471


in reply to How do I read the files in @ARGV one by one

How do you distinguish filenames from contents of files in your data structure? A hash of arrays is cleaner.

The following snippet should work:

$data{$_} = [] foreach @ARGV; while (<>) { push @{$data{$ARGV}}, $_; }
The purpose of the first line is to make sure that files which are empty are included in your hash.