Thank you Felix and Bob. I see I was approaching this compeltely wrong. Craig Hammer
-----Original Message----- From: Felix Geerinckx [mailto:[EMAIL PROTECTED]] Sent: Wednesday, May 29, 2002 8:23 AM To: [EMAIL PROTECTED] Subject: Re: converting a hash to an array 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] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]