Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: making 3 files into one

by skywalker (Beadle)
on Feb 17, 2009 at 18:05 UTC ( [id://744503]=note: print w/replies, xml ) Need Help??


in reply to making 3 files into one

Why dont you slurp each file into any array then use a for loop to print 1 record from each file at a time

quick bit of code

use strict; my @file1 = ("1 G","2 F","4 H","8 T"); my @file2 = ("5 Y","6 R","7 E","8 I"); my @file3 = ("2 H","4 T","3 G","8 R"); my $largest_array = scalar @file1; $largest_array = scalar @file2 if(scalar @file2 > $largest_array); $largest_array = scalar @file3 if(scalar @file3 > $largest_array); my @array =(\@file1,\@file2,\@file3); for (my $ctr =0;$ctr <= $largest_array;$ctr++){ print $array[0][$ctr] if($ctr <= scalar @{$array[0]}); print $array[1][$ctr] if($ctr <= scalar @{$array[1]}); print $array[2][$ctr] if($ctr <= scalar @{$array[2]}); print "\n"; } print "\n\nComplete";

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (5)
As of 2024-03-29 13:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found