develooper Front page | perl.beginners | Postings from April 2002

Concatenating

Thread Next
From:
james poni
Date:
April 26, 2002 23:46
Subject:
Concatenating
Message ID:
F147SvUC9y3jVON3sov00001479@hotmail.com
Hello
I have 3 text files and i want to perform concatenation from each line of 
the 3 files.

I want the output to look like this:

aaa mon 1
bbb wed 2
ccc sun 3
ddd tue 4

Is it possible to sort the days column in order of the week? Eg

ccc sun 3
aaa mon 1
ddd tue 4
bbb wed 2


This is my code below:

#!/usr/local/bin/perl -w

$line1 = "aaa\nbbb\nccc\nddd\n";
$line2 = "mon\nwed\nsun\ntue\n";
$line3 = "1\n2\n3\n4\n";

open ( ALPH, ">place.txt" ) || die "Cant open\n";

print ALPH $line1;

close ALPH;

open (AP, "<place.txt" )  || die "Cant open\n";

@info = <AP>;

close AP;



open ( DAY, ">day.txt" ) || die "Cant open\n";

print DAY $line2;

close DAY;

open (DA, "<day.txt" )  || die "Cant open\n";

@info2 = <DA>;

close DA;


open ( NUM, ">numb.txt" ) || die "Cant open\n";

print NUM $line3;

close NUM;

open ( NU, "<numb.txt" ) || die "Cant open\n";

@info3 = <NU>;

close NU;

for $row ((@info) && (@info2) && (@info3)) {
     $row=(pop @info)." ".(pop @info2)." ".(pop @info3);

    print $row;

}


Thanks








_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp.


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About