Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

Re: Open multiple file handles?

by John M. Dlugosz (Monsignor)
on May 07, 2011 at 04:05 UTC ( #903491=note: print w/replies, xml ) Need Help??

in reply to Open multiple file handles?

As davido indicates, you don't need to know which file you are reading from, just read all the content from all the files. So the built-in <> operator will do the trick. You can copy @ARGV to another array or produce the first line ahead of time, before consuming the arguments.

Use a hash to hold the data you are building. From the example, you read (key,value) pairs from the input. Then you output, for each key, all the values it had been used with. after reading $key and $value, do a push @{$concordance{$key}},$value;. Then when you are all done, something like

while (my ($key, $vals)=each %concordance) { say $key, ' ', join(' ', @$vals); }

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://903491]
[moritz]: ovedpo15 "use lib" is only for .pm files
[moritz]: if you don't have .pm file, you might to use "require" or "do" with an absolute path
[ovedpo15]: I need to use FindBin thought. does FindBin finds only modules? or it can find perl script also?
[moritz]: maybe you should start looking at the documentation of FindBin?

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (6)
As of 2018-03-17 20:47 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (226 votes). Check out past polls.