Mark Bedish wrote:
>  Dave,
> 
> >It looks to me that your hash %ch is empty.  Your
> >foreach will never begin because there is no list
> to
> >iterate.  You need to assign keys & values to %ch.
> 
> >When it is time to sort numerically, use the
> spaceship
> >operator <=>.  So it would look like this:
> 
> >sort { $ch{1} <=> $ch{2} }
> 
> No I have got the data, I didnt show the full
> example. My tab delimited
> file is something like this:
> 
> Complete music of Ockeghem    380
> Bach Cantatas bwv140 etc     113
> Achirana Marshall Trio     48
> Hello Children     145
[snip]

Mark,

OK, I understand.  Using the data you provided above,
this code worked for me:

------------------
my (%ch, @fields);

open(FILE, "data");
while (<FILE>) {
        chomp;
        @fields = split(/\t/);
        $ch{$fields[0]} = $fields[1];
}
close FILE;

for (sort { $ch{$a} <=> $ch{$b} } keys %ch) {
        print "$_: $ch{$_}\n";
}



=====
Dave Hoover
"Twice blessed is help unlooked for." --Tolkien
http://www.redsquirreldesign.com/dave

__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/

Reply via email to