Beefy Boxes and Bandwidth Generously Provided by pair Networks chromatic writing perl on a camel
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Merging 3 files

by CombatSquirrel (Hermit)
on Dec 18, 2003 at 05:34 UTC ( [id://315487]=note: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


in reply to Merging 3 files

Why woldn't you just do something like the following (untested, sorry):
#!perl use strict; use warnings; my @handles; my $i = 0; for (@ARGV) { open $handles[$i++], '<', $_ or die "Failed to open $_: $!\n"; } my $line; $i = 0; while (1) { $line = <$handles[$i]>; defined($line) or last; print $line; } continue { ++$i; $i %= @handles; } close $_ for @handles;

Hope this helped.
CombatSquirrel.

Update: Closed files. Thanks to b10m.
Entropy is the tendency of everything going to hell.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://315487]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.