Re: picking largest key by value..

2009-02-28 Thread Chas. Owens
On Sat, Feb 28, 2009 at 07:13, Chas. Owens wrote: snip > Depends on your version of Perl.  Perl prior to 5.8.1 the order of a > set of keys in a hash was always the same (but unordered). snip This should read: Perl prior to 5.8.1 the order of a set of keys in a hash was always the same (

Re: picking largest key by value..

2009-02-27 Thread Rick
Jim Gibson wrote: On 2/27/09 Fri Feb 27, 2009 8:33 AM, "Rick" scribbled: Jim Gibson wrote: On 2/26/09 Thu Feb 26, 2009 3:53 PM, "John W. Krahn" scribbled: I get "Use of uninitialized value in numeric gt (>) at ..." for that, since @max is undefined the first time through the

Re: picking largest key by value..

2009-02-27 Thread Rick
Jim Gibson wrote: NO it is not. The way to diagnosis this type of problem is to look at the contents of your variables, either by stepping through your program with a debugger or by adding print statements to your program. If you do that, you will find that the @next array is not assigned the key

Re: picking largest key by value..

2009-02-27 Thread Jim Gibson
On 2/27/09 Fri Feb 27, 2009 8:33 AM, "Rick" scribbled: > Jim Gibson wrote: >> On 2/26/09 Thu Feb 26, 2009 3:53 PM, "John W. Krahn" >> scribbled: >> >> I get "Use of uninitialized value in numeric gt (>) at ..." for that, since >> @max is undefined the first time through the loop. Here is

Re: picking largest key by value..

2009-02-27 Thread Rick
Jim Gibson wrote: On 2/26/09 Thu Feb 26, 2009 3:53 PM, "John W. Krahn" scribbled: I get "Use of uninitialized value in numeric gt (>) at ..." for that, since @max is undefined the first time through the loop. Here is a version using each that doesn't produce that error. It uses the fact th

Re: picking largest key by value..

2009-02-26 Thread Jim Gibson
On 2/26/09 Thu Feb 26, 2009 3:53 PM, "John W. Krahn" scribbled: > Rick wrote: >> trying out getting lasrgest key(by value) but below is not working... >> >> help please. >> >> my %files=%{{"one" =>"1", "thiry" =>"30", "four" =>"4", "never" =>"997", >> "forever" =>"11", "five" =>"5"}}; >>

Re: picking largest key by value..

2009-02-26 Thread John W. Krahn
Rick wrote: trying out getting lasrgest key(by value) but below is not working... help please. my %files=%{{"one" =>"1", "thiry" =>"30", "four" =>"4", "never" =>"997", "forever" =>"11", "five" =>"5"}}; my $max; print join(" ",keys %files),"\n"; =pod grep($max=($files{$_} > $max )? $_ : $

Re: picking largest key by value..

2009-02-26 Thread Gunnar Hjalmarsson
Rick wrote: trying out getting lasrgest key(by value) my %files=%{{"one" =>"1", "thiry" =>"30", "four" =>"4", "never" =>"997", "forever" =>"11", "five" =>"5"}}; Any special reason why you say my %files = %{{ ... }}; instead of simply my %files = ( ... ); ? While this sugge

Re: picking largest key by value..

2009-02-26 Thread rich . japh
Will try that once I get back --Original Message-- From: Owen To: beginners@perl.org Subject: Re: picking largest key by value.. Sent: Feb 26, 2009 3:53 PM On Thu, 26 Feb 2009 15:34:11 -0500 Rick wrote: > trying out getting lasrgest key(by value) but below is not working... >

Re: picking largest key by value..

2009-02-26 Thread Rick
Rick wrote: trying out getting lasrgest key(by value) but below is not working... help please. my %files=%{{"one" =>"1", "thiry" =>"30", "four" =>"4", "never" =>"997", "forever" =>"11", "five" =>"5"}}; my $max; print join(" ",keys %files),"\n"; =pod grep($max=($files{$_} > $max )? $_ : $

Re: picking largest key by value..

2009-02-26 Thread Owen
On Thu, 26 Feb 2009 15:34:11 -0500 Rick wrote: > trying out getting lasrgest key(by value) but below is not working... > > help please. > > my %files=%{{"one" =>"1", "thiry" =>"30", "four" =>"4", "never" > =>"997", "forever" =>"11", "five" =>"5"}}; > my $max; > print join(" ",keys %files),"

Re: picking largest key by value..

2009-02-26 Thread Jim Gibson
On 2/26/09 Thu Feb 26, 2009 12:34 PM, "Rick" scribbled: > trying out getting lasrgest key(by value) but below is not working... > > help please. > > my %files=%{{"one" =>"1", "thiry" =>"30", "four" =>"4", "never" =>"997", > "forever" =>"11", "five" =>"5"}}; > my $max; > print join(" ",key

picking largest key by value..

2009-02-26 Thread Rick
trying out getting lasrgest key(by value) but below is not working... help please. my %files=%{{"one" =>"1", "thiry" =>"30", "four" =>"4", "never" =>"997", "forever" =>"11", "five" =>"5"}}; my $max; print join(" ",keys %files),"\n"; =pod grep($max=($files{$_} > $max )? $_ : $max,keys %fil