Steveo wrote:
> 
> I understand how to sort $string1 and $string2 but I have something a
> little more complicated (I think at least) and I've never done this
> before.  This is what my data looks like (flat ascii file)
> 
> (clan, wins, losses, points for, points against)
> 
> dod,4,3,700,400
> cs,5,2,950,250
> hl,0,7,300,1000
> 
> What I want to do is read this flat ascii text file into a script and print
> it out on a webpage so the clans are ranked by wins, so on a webpage it
> would look like this:
> 
> Clan     W     L     PF     PA
> 
> CS       5     2      950    250
> DOD     4     3       700   400
> HL       0      7       300   1000
> 
> I can open and close the ascii text file.  Whats an approach for going
> about sorting this data?


Something like this should work:

open FILE, 'somefile' or die "Cannot open 'somefile': $!";

printf "%-5s %8s %8s %8s %8s\n", qw(Clan W L PF PA);
printf "%-5s %8d %8d %8d %8d\n", @$_
    for sort { $b->[1] <=> $a->[1] }
        map  { [ split /,/ ] } <FILE>;



John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to