Re: hash keys and readable code

2009-11-11 Thread Uri Guttman
> "PP" == Philip Potter writes: PP> 2009/11/11 Uri Guttman : >> you can also simplify the copy a little with a hash ref: >> >> my $readfsgs_flags = { map { $_ => $flags->{$_} } @flags_to_copy } ; PP> Is this really simpler than my version? PP> @readfsgs_fla...@flags_to_copy} =

Re: hash keys and readable code

2009-11-11 Thread Philip Potter
2009/11/11 Uri Guttman : >> "PP" == Philip Potter writes: > >  PP>     my %readfsgs_flags; >  PP>     my @flags_to_copy = qw(limit); # can scale up by adding more hash > keys here >  PP>     @readfsgs_fla...@flags_to_copy} = @{$flag...@flags_to_copy}; >  PP>     my @results = readfsgs($testfi

Re: hash keys and readable code

2009-11-11 Thread Uri Guttman
> "PP" == Philip Potter writes: PP> my %readfsgs_flags; PP> my @flags_to_copy = qw(limit); # can scale up by adding more hash keys here PP> @readfsgs_fla...@flags_to_copy} = @{$flag...@flags_to_copy}; PP> my @results = readfsgs($testfilename, \%readfsgs_flags); PP>

Re: hash keys

2008-06-12 Thread John W. Krahn
Paul Lalli wrote: On Jun 12, 12:15 am, [EMAIL PROTECTED] (Beast) wrote: Why this following code has not working as expected? print "Number of element(s) : " . sprintf("%10d", keys(%hash) ) . "\n"; The keys() function does two different things, depending on context. In scalar context, it

Re: hash keys

2008-06-12 Thread Paul Lalli
On Jun 12, 12:15 am, [EMAIL PROTECTED] (Beast) wrote: > Why this following code has not working as expected? > >     print "Number of element(s) : " . sprintf("%10d", keys(%hash) ) . "\n"; The keys() function does two different things, depending on context. In scalar context, it returns the numb

Re: hash keys

2008-06-11 Thread Rob Dixon
beast wrote: > Hi All, > > > Why this following code has not working as expected? > > print "Number of element(s) : " . sprintf("%10d", keys(%hash) ) . "\n"; keys(%hash) returns the hash keys as a list, so sprintf("%10d", keys(%hash) ) is like sprintf("%10d", 'key3', 'key4', 'key1',

Re: hash keys

2008-06-11 Thread Rodrick Brown
On Thu, Jun 12, 2008 at 12:15 AM, beast <[EMAIL PROTECTED]> wrote: > Hi All, > > > Why this following code has not working as expected? > >print "Number of element(s) : " . sprintf("%10d", keys(%hash) ) . "\n"; > Try: print "Number of element(s): " . sprintf("%10d", scalar keys(%h)),"\n"; >

Re: hash keys

2006-05-02 Thread Jay Savage
On 5/2/06, Rance Hall <[EMAIL PROTECTED]> wrote: the set of hash keys is what the computer uses to find values in the hash, and in order to optimize your code and make searching the hash for specific values as fast as possible, you should WANT your key to be as short and simple as possible but s

Re: hash keys

2006-05-02 Thread Rance Hall
Ryan Perry wrote: Generally, your hash value is larger than you key ( $hash{key}="Some text, maybe a sentence or two"). Is there any reason I should not reverse this relationship? ($hash{"Some text, maybe a sentence or two"}='key') Thanks! the set of hash keys is what the com

Re: hash keys

2006-05-01 Thread John W. Krahn
Ryan Perry wrote: > Generally, your hash value is larger than you key ( $hash{key}="Some > text, maybe a sentence or two"). Is there any reason I should not > reverse this relationship? ($hash{"Some text, maybe a sentence or > two"}='key') The only rules are that hash keys are converte

Re: hash keys

2006-05-01 Thread Tom Phoenix
On 5/1/06, Ryan Perry <[EMAIL PROTECTED]> wrote: Generally, your hash value is larger than you key ( $hash{key}="Some text, maybe a sentence or two"). Is there any reason I should not reverse this relationship? ($hash{"Some text, maybe a sentence or two"}='key') There's no law against

Re: hash keys

2006-05-01 Thread Jeff Pang
>Generally, your hash value is larger than you key ( $hash{key}="Some >text, maybe a sentence or two"). Is there any reason I should >not reverse this relationship? ($hash{"Some text, maybe a sentence or >two"}='key') There is not such rule for comparing Key and Value's size. For e

RE: HASH keys in exact order

2005-12-22 Thread Timothy Johnson
There are a couple of kludgy ways to do this, but any time you find yourself wanting to do this you have to stop and make sure that what you are attempting is really what you want to have happen. 99% of the time what you really want is an array. -Original Message- From: Causevic, Dzena

Re: HASH keys in exact order

2005-12-22 Thread Paul Johnson
On Thu, Dec 22, 2005 at 05:18:35PM -0500, Causevic, Dzenan wrote: > I am trying to print HASH keys in exact order as they are defined, but > "keys %HASH" returns them in a random order, "sort" is not going to > work either because keys are strings that are not defined in the exact > alphabetical o

Re: hash keys

2001-11-08 Thread kim,kiseok
use utf8; # Perl pragma to enable/disable UTF-8 in source code and save as utf8 format. see "Martin Pfeffer" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED]... > hi to all > Does anyone knows a workaround to use characters like the "ñ" for > example Español as hashkeys ? > I get the

Re: Hash keys

2001-10-03 Thread Brett W. McCoy
On Wed, 3 Oct 2001, Tyler Cruickshank wrote: > I have a hash that I am storing arrays in. Each array corresponds to > one hour of a day. After the hash has been populated I need to cycle > through the "days" and sum them up. So, I have written my hash such > that each key can be looped thru vi

Re: Hash keys

2001-10-03 Thread Michael Fowler
On Wed, Oct 03, 2001 at 03:12:55PM -0600, Tyler Cruickshank wrote: > I have a hash that I am storing arrays in. Each array corresponds to one > hour of a day. After the hash has been populated I need to cycle through > the "days" and sum them up. So, I have written my hash such that each key >

Re: Hash keys

2001-10-03 Thread Curtis Poe
--- Tyler Cruickshank <[EMAIL PROTECTED]> wrote: > My keys are simply data.hr1, data.hr2, data.hr3, where each key is incremented via >the for loop. > The problem seems to be that when I use $specSum{$name}[$i] where $name would be >data.hr1, > data.hr2, data.hr3 ... it doesnt work. How can I