Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: parallel reading

by blazar (Canon)
on May 09, 2006 at 13:49 UTC ( #548210=note: print w/replies, xml ) Need Help??


in reply to parallel reading

Since others already gave you good general purpose suggestions...

#!/usr/bin/perl -l use strict; use warnings; my @fh=map { open my $fh, '<', $_ or die "Can't open `$_': $!\n"; $fh } @ARGV; while (@fh) { @fh=grep !eof $_, @fh; print map { chomp(my $line=<$_>); $line } @fh; } __END__

Replies are listed 'Best First'.
Re^2: parallel reading
by roboticus (Chancellor) on May 09, 2006 at 19:15 UTC
    blazar:

    Very nice (++)! I've never used map before, but that's an eye opener. It's so much better than my (admittedly terrible) hack, and clear to boot. That example is going on my "cheatsheet" of tips I keep pinned to my cube wall.

    --roboticus

      Now that you know... beware! It's easy to get addicted to map & grep. They're good for... the jobs they're good for! Do not abuse them!

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://548210]
help
Chatterbox?
[stevieb]: Hey ww. Just laying down watching a hockey game, running my auto build distribution that automates Strawberry installs to figure out which ones had csum changes so berrybrew doesn't barf on those ones
[stevieb]: ...and closing some issues on some of my other dists

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (5)
As of 2017-03-30 02:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should Pluto Get Its Planethood Back?



    Results (353 votes). Check out past polls.