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

Re: Merging files, 1 line for every 10

by ForgotPasswordAgain (Deacon)
on Sep 06, 2011 at 22:14 UTC ( #924475=note: print w/ replies, xml ) Need Help??


in reply to Merging files, 1 line for every 10

Say that you read each file into an array.

use File::Slurp; my @file1 = read_file('file1'); my @file2 = read_file('file2');

Where would you go from there? Eventually you could have a new array, write it out like this:

my $lines = merge_lines(\@file1, \@file2); write_file('file3', @$lines);

How would you write 'merge_lines'?

sub merge_lines { my ($lines1, $lines2) = @_; my @lines; .... return \@lines; }

Not the most efficient way to do it, but...


Comment on Re: Merging files, 1 line for every 10
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (10)
As of 2015-07-08 00:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (93 votes), past polls