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

Concatenating Again

Thread Next
From:
james poni
Date:
April 28, 2002 07:31
Subject:
Concatenating Again
Message ID:
F145zyJxArGvnCjnZS00000038f@hotmail.com
Hello again

I slightly changed the input but icant seem to get the output like this
below:
bbb beta sun 1,1
aaa aplha mon 2,2
ddd delta tue 3,3
ccc gamma wed 4,4

How would i modify this program in order to do so ?


THIS I THE PROGRAM
$line1 = "aaa alpha\nbbb beta\nccc gamma\nddd  delta\n";
$line2 = "mon\nwed\nsun\ntue\n";
$line3 = "1, 1\n2, 2\n3, 3\n4, 4\n";

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

print ALPH $line1;

close ALPH;

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

$info1 = <AP>;

close AP;



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

print DAY $line2;

close DAY;

open (DA, "<da.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;

my @info;
my %days = (
	    sun => 0,
	    mon => 1,
	    tue => 2,
	    wed => 3,
	    thu => 4,
	    fri => 5,
	    sat => 6,
	    );



my $count;
chomp, push @{$info[$count++]}, $_ for <@info1>;
$count = 0;
chomp, push @{$info[$count++]}, $_ for <@info2>;
$count = 0;
chomp, push @{$info[$count++]}, $_ for <@info3>;

@info = sort { $days{$a->[1]} <=> $days{$b->[0]}  } @info;

for my $row ( @info ) {
    print "@$row\n";
}


Thanks

_________________________________________________________________
Chat with friends online, try MSN Messenger: http://messenger.msn.com


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