Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Multiple file handling

by moritz (Cardinal)
on Sep 12, 2012 at 14:38 UTC ( #993234=note: print w/ replies, xml ) Need Help??


in reply to Multiple file handling

Scenario: A variable is mentioned in multiple file names and im able to grep once only.

Why should that be the case? That sounds like a rather odd restriction. If you absolutely must work with that restriction, you can do something like

use autodie; use List::MoreUtils qw/uniq/; open my $F1, $filename1; open my $F2, $filename2; my @files = unique map $_->[0], grep $_->[1] =~ /$variable/, (map [$filename1, $_] <$F1>), (map [$filename2, $_] <$F2>), ;

Of course that code is much slower and uses much more memory than if you'd just search file by file.


Comment on Re: Multiple file handling
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://993234]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (7)
As of 2014-12-21 20:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (107 votes), past polls