Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re^2: Use 2 files and print each line of each one side-by-side

by Util (Priest)
on Feb 19, 2014 at 03:40 UTC ( [id://1075417]=note: print w/replies, xml ) Need Help??


in reply to Re: Use 2 files and print each line of each one side-by-side
in thread Use 2 files and print each line of each one side-by-side

Also for fun, a Perl 6 version.
Note that this only works for files of the same length, because Z terminates (without error) when the shorter list ends.

use v6; sub MAIN ( $in_path1, $in_path2, $out_path = 'CONCATENATED_FILES' ) { my $in1 = open $in_path1, :r; my $in2 = open $in_path2, :r; my $out = open $out_path, :w; for $in1.lines Z $in2.lines -> $line1, $line2 { $out.say: "$line1\t$line2"; } .close for $out, $in1, $in2; }

Log In?
Username:
Password:

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

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

    No recent polls found