Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

Re (tilly) 1: How do I read the files in @ARGV one by one

by tilly (Archbishop)
on Mar 19, 2001 at 21:30 UTC ( #65471=note: print w/replies, xml ) Need Help??

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.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://65471]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (2)
As of 2017-07-24 02:19 GMT
Find Nodes?
    Voting Booth?
    I came, I saw, I ...

    Results (347 votes). Check out past polls.