on Wed, 29 May 2002 12:58:33 GMT, [EMAIL PROTECTED] (Craig
Hammer) wrote:
> I thought this would work:
Your code is very buggy:
> @sorted = sort { $myhash{$b} <=> $myhash{a} } keys %myhash ;
This should read:
@sorted = sort { $myhash{$b} <=> $myhash{$a} } keys %myhash ;
^
Now '@sorted' contains the keys of your '%myhash', sorted
numerically, largest first.
> while ( <@sorted> ) {
Since '@sorted' is not a filehandle, this will be interpreted as a
glob("something"), where "something" is the catenation of all your
hashkeys, thus looping over all files in the current working
directory that fit the "something" fileglob (probably none).
You want
for(@sorted) {
# whatever
}
> printf ( "first field = %s second field = %s\n", $sorted{1},
> $sorted{2}
> ) ;
'@sorted' is an array, not a hash, $sorted{something} will not work.
--
felix
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]