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

Concatenation , the final time

From:
james poni
Date:
April 29, 2002 04:17
Subject:
Concatenation , the final time
Message ID:
F89S79AX7Ur5qWn3GCI000010e5@hotmail.com



>From: "james poni" <jamespoini@hotmail.com>
>To: beginners@perl.org
>Subject: Concatenating , the final time
>Date: Mon, 29 Apr 2002 11:57:18 +1000
>
>
>
>Hello again (final time)
>
>I also want to sort the  (number time) field when we have the same day
>eg:
>
>below:
>ccc gamma sun 3:00
>aaa aplha mon 1:00   <<here the days are sorted as
>eee epsilon mon 3:00  <<as well as the time
>zzz zeta mon 4:00      << is sorted if the same day
>ddd delta tue 1:00  <<
>iii ita tue 1:30    << this is greater
>bbb beta wed 2:00
>
>How would i modify this program in order to do so ? Do i need a time hash 
>eg
>time = (12:00 =>1,12:30=>2,13:00=>3,13:30=>4 ......) ?
>
>
>THIS THE PROGRAM
>$line1 = "aaa alpha\nbbb beta\nccc gamma\nddd  delta\neee epsilon\nzzz
>zeta\niiii ita\n";
>$line2 = "mon\nwed\nsun\ntue\nmon\nmon\ntue\n";
>$line3 = "1:00\n2:00\n3:00\n1:00\n3:00\n4:00\n1:30\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->[1]}  } @info;
>
>I think i need another sort for time here but im not entirely sure how this
>sort above sort works?
>
>for my $row ( @info ) {
>   print "@$row\n";
>}
>
>
>Thanks
>James
>
>
>_________________________________________________________________
>MSN Photos is the easiest way to share and print your photos:
>http://photos.msn.com/support/worldwide.aspx
>
>
>--
>To unsubscribe, e-mail: beginners-unsubscribe@perl.org
>For additional commands, e-mail: beginners-help@perl.org
>




_________________________________________________________________
Join the worldÂ’s largest e-mail service with MSN Hotmail. 
http://www.hotmail.com




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