Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re^2: How do you create a tab delimited txt file from two files?

by k_manimuthu (Monk)
on Jul 29, 2010 at 08:06 UTC ( [id://851873]=note: print w/replies, xml ) Need Help??


in reply to Re: How do you create a tab delimited txt file from two files?
in thread How do you create a tab delimited txt file from two files?

I consider the file1 and the file2 contents are equal numbers

use strict; use warnings; ### open the first file and store in to a array format open (F1, "file1.txt") || die "Cannot open the input file : $!"; my @file1=<F1>; close (F1); ### open the second file and store in to a array format open (F2, "file2.txt") || die "Cannot open the input file : $!"; my @file2=<F2>; close (F2); my @file3; ### process each element and store the file1 and the corresponding ### value in second file in another one array for (my $i=0; $i<=$#file1; $i++) { chomp($file1[$i]); push @file3, "$file1[$i]\t$file2[$i]"; } ### print the array in a output file open (FOUT, ">Concat.txt") || die "Cannot create the output file"; print FOUT @file3; close (FOUT);

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (2)
As of 2024-03-19 06:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found