Re: How to navigate through a hash of hashes of arrays (?) to get to the first array entry

2016-04-15 Thread Shlomi Fish
Hi Raj, On Thu, 14 Apr 2016 16:15:08 + Raj Barath wrote: > I was wrong. Please don't use my example. > Aaron wells explanation is perfect. > Thanks for admitting you were wrong - many people fail to do so. I agree that Aaron Wells's explanation appears to be very good, and one can find mor

Re: How to navigate through a hash of hashes of arrays (?) to get to the first array entry

2016-04-14 Thread Raj Barath
I was wrong. Please don't use my example. Aaron wells explanation is perfect. Apologies for the confusion. -Raj On Thu, Apr 14, 2016 at 11:15 AM, Aaron Wells mailto:chacewe...@gmail.com>> wrote: Hi Kenneth, Welcome aboard (for the nth time)! The replies on this thread have been helpful, but

Re: How to navigate through a hash of hashes of arrays (?) to get to the first array entry

2016-04-14 Thread Raj Barath
I was wrong. Please don't use my example. Aaron wells explanation is perfect. Apologies for the confusion. -Raj On Thu, Apr 14, 2016 at 11:15 AM, Aaron Wells mailto:chacewe...@gmail.com>> wrote: Hi Kenneth, Welcome aboard (for the nth time)! The replies on this thread have been helpful, but

Re: How to navigate through a hash of hashes of arrays (?) to get to the first array entry

2016-04-14 Thread Aaron Wells
Hi Kenneth, Welcome aboard (for the nth time)! The replies on this thread have been helpful, but they haven’t really addressed the underlying issue, which is that there’s subscripting, then there’s dereferencing. I’ll try to keep my explanation brief, but first a solution: $confused = [ bl

Re: How to navigate through a hash of hashes of arrays (?) to get to the first array entry

2016-04-14 Thread Shlomi Fish
Hello Raj, On Thu, 14 Apr 2016 03:52:56 + Raj Barath wrote: > Hello Kenneth, > > Check this out: > > use v5.22; > use Data::Dumper; > > my $VAR1; > > $VAR1 = [ > bless( { >'Id' => [ >'01tC003udXAIAY', >

Re: How to navigate through a hash of hashes of arrays (?) to get to the first array entry

2016-04-14 Thread Raj Barath
Hello Kenneth, Check this out: use v5.22; use Data::Dumper; my $VAR1; $VAR1 = [ bless( { 'Id' => [ '01tC003udXAIAY', '01tC003udXAIAY' ], 'type' => 'Product2'

Re: How to navigate through a hash of hashes of arrays (?) to get to the first array entry

2016-04-14 Thread Raj Barath
Hello Kenneth, Check this out: use v5.22; use Data::Dumper; my $VAR1; $VAR1 = [ bless( { 'Id' => [ '01tC003udXAIAY', '01tC003udXAIAY' ], 'type' => 'Product2'

Re: How to navigate through a hash of hashes of arrays (?) to get to the first array entry

2016-04-13 Thread Kenneth Wolcott
On Wed, Apr 13, 2016 at 7:13 PM, Ken Slater wrote: > > On Wed, Apr 13, 2016 at 9:29 PM, Kenneth Wolcott > wrote: >> >> Hi; >> >> I have the following output from Data::Dumper and I want to extract >> the first string that the "Id" name points to. >> >> $VAR1 = [ >> bless( { >>

Re: How to navigate through a hash of hashes of arrays (?) to get to the first array entry

2016-04-13 Thread Lawrence Statton
On 04/13/2016 08:29 PM, Kenneth Wolcott wrote: Hi; I have the following output from Data::Dumper and I want to extract the first string that the "Id" name points to. $VAR1 = [ bless( { 'Id' => [ '01tC003udXAIAY',

Re: How to navigate through a hash of hashes of arrays (?) to get to the first array entry

2016-04-13 Thread Ken Slater
On Wed, Apr 13, 2016 at 9:29 PM, Kenneth Wolcott wrote: > Hi; > > I have the following output from Data::Dumper and I want to extract > the first string that the "Id" name points to. > > $VAR1 = [ > bless( { >'Id' => [ >'01tC003udXAI

How to navigate through a hash of hashes of arrays (?) to get to the first array entry

2016-04-13 Thread Kenneth Wolcott
Hi; I have the following output from Data::Dumper and I want to extract the first string that the "Id" name points to. $VAR1 = [ bless( { 'Id' => [ '01tC003udXAIAY', '01tC003udXAIAY'

Re: Hash of Hashes - Error

2011-08-25 Thread Mike McClain
> On Tue, Aug 23, 2011 at 10:23 AM, wrote: > I am working on the below code to traverse through a hash, but it throws an > error which states "Can't coerce array into hash at temp.pl line 6." > > Code: > === > sub hash_walk { >my

Re: Hash of Hashes - Error

2011-08-24 Thread AKINLEYE
When you shift off a variable you pop it out of the argument . Just try and get the first variable of the argument another way by copying to an array first or something . from perldoc Shift : Shifts the first value of the array off and returns it, shortening the array by 1 and moving everything do

Hash of Hashes - Error

2011-08-24 Thread anand.jawaji
Hi All, I am working on the below code to traverse through a hash, but it throws an error which states "Can't coerce array into hash at temp.pl line 6." Code: === sub hash_walk { my $self = shift; my ($hash, $key_list, $ca

RE: Hash of Hashes - Error

2011-08-23 Thread anand.jawaji
Thanks a lot for the suggestions and solution. Regards, Anand -Original Message- From: Shlomi Fish [mailto:shlo...@shlomifish.org] Sent: Tuesday, August 23, 2011 5:09 PM To: Jawaji, Anand Cc: beginners@perl.org Subject: Re: Hash of Hashes - Error Hi Anand, On Tue, 23 Aug 2011 05:57:02

Re: Hash of Hashes - Error

2011-08-23 Thread Shlomi Fish
Hi Anand, On Tue, 23 Aug 2011 05:57:02 -0400 wrote: > Hi All, > > I am working on the below code to traverse through a hash, but it throws an > error which states "Can't coerce array into hash at temp.pl line 6." > First of all, let me note that the indentation on that code is inconsistent an

RE: Hash of Hashes - Error

2011-08-23 Thread Ken Slater
> -Original Message- > From: anand.jaw...@emc.com [mailto:anand.jaw...@emc.com] > Sent: Tuesday, August 23, 2011 5:57 AM > To: beginners@perl.org > Subject: Hash of Hashes - Error > > Hi All, > > I am working on the below code to traverse through a hash, but

Hash of Hashes - Error

2011-08-23 Thread anand.jawaji
Hi All, I am working on the below code to traverse through a hash, but it throws an error which states "Can't coerce array into hash at temp.pl line 6." Code: === sub hash_walk { my $self = shift; my ($hash, $key_list, $ca

Re: retrieving key from hash of hashes

2011-04-29 Thread Rob Dixon
On 29/04/2011 10:15, Agnello George wrote: sorry i ment if (stdout == keys (%$retrn{$stdout}) ) { ##so some code } Erm, perhaps if ($stdout == keys %{$retrn{$stdout}}) { But that would compare the value of $stdout with the /number/ of keys in the hash, which is always

Re: retrieving key from hash of hashes

2011-04-29 Thread Uri Guttman
> "AG" == Agnello George writes: AG> sorry i ment AG>if (stdout == keys (%$retrn{$stdout}) ) { AG>##so some code AG> } i don't think you are getting it yet. keys gets you the list of keys ONLY in a list context. == provides a scalar context which will get you the

Re: retrieving key from hash of hashes

2011-04-29 Thread Rob Dixon
On 29/04/2011 10:14, Agnello George wrote: On Fri, Apr 29, 2011 at 2:33 PM, Rob Dixon wrote: On 29/04/2011 09:47, Agnello George wrote: my %retrn = ( 0 =>{ 0 =>' successful'}, 1 =>{ 1 =>'insufficient'}, 2 =>{ 2 =>'txtfile missing'}, 3 =>

Re: retrieving key from hash of hashes

2011-04-29 Thread Agnello George
On Fri, Apr 29, 2011 at 2:44 PM, Agnello George wrote: > On Fri, Apr 29, 2011 at 2:33 PM, Rob Dixon wrote: >> On 29/04/2011 09:47, Agnello George wrote: >>> >>>  my %retrn = ( 0 =>  { 0 =>  '  successful'}, >>>         1 =>  { 1 =>  'insufficient'}, >>>         2 =>  { 2 =>  'txtfile missing'}, >

Re: retrieving key from hash of hashes

2011-04-29 Thread Agnello George
On Fri, Apr 29, 2011 at 2:33 PM, Rob Dixon wrote: > On 29/04/2011 09:47, Agnello George wrote: >> >>  my %retrn = ( 0 =>  { 0 =>  '  successful'}, >>         1 =>  { 1 =>  'insufficient'}, >>         2 =>  { 2 =>  'txtfile missing'}, >>         3 =>  { 3 =>  'bad dir'}, >>         ); >> >> ( i kno

Re: retrieving key from hash of hashes

2011-04-29 Thread Rob Dixon
On 29/04/2011 09:47, Agnello George wrote: my %retrn = ( 0 => { 0 => ' successful'}, 1 => { 1 => 'insufficient'}, 2 => { 2 => 'txtfile missing'}, 3 => { 3 => 'bad dir'}, ); ( i know this hash looks funny , but is the hash i got to use ) suppose $s

Re: retrieving key from hash of hashes

2011-04-29 Thread John W. Krahn
Agnello George wrote: Hi All Hello, I got a hash like this : my %retrn = ( 0 => { 0 => ' successful'}, 1 => { 1 => 'insufficient'}, 2 => { 2 => 'txtfile missing'}, 3 => { 3 => 'bad dir'}, ); ( i know this hash looks funny , but is the hash i g

retrieving key from hash of hashes

2011-04-29 Thread Agnello George
Hi All I got a hash like this : my %retrn = ( 0 => { 0 => ' successful'}, 1 => { 1 => 'insufficient'}, 2 => { 2 => 'txtfile missing'}, 3 => { 3 => 'bad dir '}, ); ( i know this hash looks funny , but is the hash i got to use ) suppose $stdout = 0; i need to

Re: Problems constructing a hash of hashes

2010-06-16 Thread Steve Bertrand
On 2010.06.16 19:36, Uri Guttman wrote: >> "CO" == Chas Owens writes: > CO> Or the online versions: > as a perl teacher i respect says, use the local docs as they are always > there ...point well taken. I will personally follow this method from now on. If any poster doesn't initially und

Re: Problems constructing a hash of hashes

2010-06-16 Thread Uri Guttman
> "CO" == Chas Owens writes: CO> On Wed, Jun 16, 2010 at 18:29, Uri Guttman wrote: CO> snip >> for more on hashes of hashes read perldoc perlreftut, perllol and >> perldsc. CO> snip CO> Or the online versions: CO> http://perldoc.perl.org/perlreftut.html CO> http://perldoc.p

Re: Problems constructing a hash of hashes

2010-06-16 Thread Chas. Owens
On Wed, Jun 16, 2010 at 18:29, Uri Guttman wrote: snip > for more on hashes of hashes read perldoc perlreftut, perllol and > perldsc. snip Or the online versions: http://perldoc.perl.org/perlreftut.html http://perldoc.perl.org/perllol.html http://perldoc.perl.org/perldsc.html -- Chas. Owens wo

Re: Problems constructing a hash of hashes

2010-06-16 Thread Uri Guttman
> "GJ" == Greg J writes: GJ> Hi everyone, GJ> I am new to Perl and I am having some trouble working with hashes of hashes. GJ> I am trying to write a simple Markov Chain text generator and thought GJ> it might be a good idea to keep track of state transitions in a hash. GJ> Here

Re: Problems constructing a hash of hashes

2010-06-16 Thread Chas. Owens
On Wed, Jun 16, 2010 at 18:02, Greg J wrote: snip > sub InsertWord > { >   my( $state, $next ) = shift @_; snip This is your big problem. You need to say my ($state, $next) = @_; or my $state = shift; my $next = shift; snip >   if( $StateTable{$state} ) >   { > if( $StateTable{$state}{

Re: Problems constructing a hash of hashes

2010-06-16 Thread Shawn H Corey
On 10-06-16 06:02 PM, Greg J wrote: Hi everyone, I am new to Perl and I am having some trouble working with hashes of hashes. I am trying to write a simple Markov Chain text generator and thought it might be a good idea to keep track of state transitions in a hash. Here is some of the code I h

Problems constructing a hash of hashes

2010-06-16 Thread Greg J
Hi everyone, I am new to Perl and I am having some trouble working with hashes of hashes. I am trying to write a simple Markov Chain text generator and thought it might be a good idea to keep track of state transitions in a hash. Here is some of the code I have.. ===

Re: Building a record on the fly via hash of hashes

2009-10-09 Thread Paul Johnson
On Fri, Oct 09, 2009 at 02:57:44PM +0530, Soham Das wrote: > Yes,indeed after you pointed out to me, I (figuratively) kicked myself. But those quotes are still ugly and unnecessary, as John showed. -- Paul Johnson - p...@pjcj.net http://www.pjcj.net -- To unsubscribe, e-mail: beginners-unsubs

Re: Building a record on the fly via hash of hashes

2009-10-09 Thread Soham Das
(figuratively) kicked myself. Thanks Soham From: Philip Potter To: Soham Das Cc: beginners@perl.org Sent: Fri, 9 October, 2009 2:22:49 PM Subject: Re: Building a record on the fly via hash of hashes 2009/10/9 Soham Das : > When I compile this, it gives me an er

Re: Building a record on the fly via hash of hashes

2009-10-09 Thread Philip Potter
2009/10/9 Soham Das : > When I compile this, it gives me an error like this: > > Can't modify constant item in scalar assignment at Test.pl line 18, near "}"; > > So for the sake of clarity I highlited the Line 18. > > 'Action'=$trades->{'Action'}, > > A bit of help in this, will be great! When pe

Re: Building a record on the fly via hash of hashes

2009-10-09 Thread Soham Das
I compile this, it gives me an error like this: Can't modify constant item in scalar assignment at Test.pl line 18, near "}"; So for the sake of clarity I highlited the Line 18. 'Action'=$trades->{'Action'}, A bit of help in this, will be great! Soham

Re: Building a record on the fly via hash of hashes

2009-10-09 Thread Soham Das
ubject: Re: Building a record on the fly via hash of hashes Soham Das wrote: > The Code: > > use strict; > use warnings; > use Tie::Handle::CSV; > > my $qbook = Tie::Handle::CSV->new('C:\Documents and Settings\Soham > Das\Desktop\Quotes.csv',header=>1); > my

Re: Building a record on the fly via hash of hashes

2009-10-08 Thread John W. Krahn
Soham Das wrote: The Code: use strict; use warnings; use Tie::Handle::CSV; my $qbook = Tie::Handle::CSV->new('C:\Documents and Settings\Soham Das\Desktop\Quotes.csv',header=>1); my $tradebook = Tie::Handle::CSV->new('C:\Documents and Settings\Soham Das\Desktop\Transactions.csv',header=>1); m

Re: Building a record on the fly via hash of hashes

2009-10-08 Thread Soham Das
} close $qbook ; close $tradebook; Soham P.S: apologies for the previous mail being a blank mail, it was a mistake From: Soham Das To: beginners@perl.org Sent: Fri, 9 October, 2009 11:02:51 AM Subject: Re: Building a record on the fly via hash of hashes T

Re: Building a record on the fly via hash of hashes

2009-10-08 Thread Soham Das
The code: From: Jim Gibson To: beginners@perl.org Sent: Fri, 9 October, 2009 11:00:55 AM Subject: Re: Building a record on the fly via hash of hashes At 10:14 PM -0700 10/8/09, Soham Das wrote: > Hello All, I am doing some file reading operation, and pars

Re: Building a record on the fly via hash of hashes

2009-10-08 Thread Jim Gibson
e contents are lost. Because the hash reference now points to the newer data. How do I overcome this? More importantly do we have a push equivalent for hash of hashes? No. Unless each record has a unique key, you are better off using an array of hashes, rather than a hash of hashes. Of course

Building a record on the fly via hash of hashes

2009-10-08 Thread Soham Das
;}}= $hashref; loop : ends Here Action, Name,System,price are the CSV headers. Now, when the first line is read, the details are parsed and stored in the $recordref as a hash reference. Now when the loop iterates, and goes to the second line. The first line contents are lost. Because the hash ref

Re: Fw: AW: Hash of Hashes

2009-09-29 Thread Uri Guttman
> "SD" == Soham Das writes: >> hashes have no positions, just keys. again. try to use standard >> terminology or you won't convey any proper meaning here. programming >> requires this to be accurate. and yes, you have been making a bunch of >> hash/array mistakes and you must fix that

Fw: AW: Hash of Hashes

2009-09-29 Thread Soham Das
- Forwarded Message From: Soham Das To: Uri Guttman Sent: Wednesday, 30 September, 2009 10:29:12 AM Subject: Re: AW: Hash of Hashes From: Uri Guttman To: Soham Das Cc: Thomas Bätzler ; beginners@perl.org Sent: Tuesday, 29 September, 2009 9

Re: AW: Hash of Hashes

2009-09-29 Thread Shawn H Corey
Uri Guttman wrote: "SD" == Soham Das writes: SD> Lets assume, the hash of hash being a record of something which SD> has already happened and hence we know the final value, not SD> something which is right now happening, i.e changeable. you keep swapping hash and array concepts, words

Re: AW: Hash of Hashes

2009-09-29 Thread Uri Guttman
> "SD" == Soham Das writes: SD> Lets assume, the hash of hash being a record of something which SD> has already happened and hence we know the final value, not SD> something which is right now happening, i.e changeable. you keep swapping hash and array concepts, words and symbols. ple

Re: Hash of Hashes

2009-09-29 Thread Shawn H Corey
Jeff Peng wrote: That's in Python? :-) Wouldn't know, don't do Python. Perl's both hash and array use (). But anonymous hash and array use {} and []. Hashes use {}, arrays use [], lists use (). When you set an element of a hash, you use {} to surround its key: $hash{$key} = $value; Wh

Re: Hash of Hashes

2009-09-29 Thread Chas. Owens
On Tue, Sep 29, 2009 at 07:40, Jeff Peng wrote: > 2009/9/29 Shawn H Corey : >> Soham Das wrote: >>> >>> How can I create a Hash of Hashes from two lists. Is it possible? >>> >>> I want the effective functionality to be served like this >>> &

Re: Hash of Hashes

2009-09-29 Thread Jeff Peng
2009/9/29 Shawn H Corey : > Soham Das wrote: >> >> How can I create a Hash of Hashes from two lists. Is it possible? >> >> I want the effective functionality to be served like this >> >> $ChildHash["Joe"]["21A"]="Sally" >>

Re: AW: Hash of Hashes

2009-09-29 Thread Soham Das
made a lot of such mistakes apparent in the previous two three mails. Soham From: Thomas Bätzler To: beginners@perl.org Cc: Soham Das Sent: Tuesday, 29 September, 2009 3:46:28 PM Subject: AW: Hash of Hashes Soham Das asked: > How can I create a Hash o

AW: Hash of Hashes

2009-09-29 Thread Thomas Bätzler
Soham Das asked: > How can I create a Hash of Hashes from two lists. Is it possible? > > I want the effective functionality to be served like this > > $ChildHash["Joe"]["21A"]="Sally" > > i.e Joe at 21A has a child called Sally. List1 here wil

Re: Hash of Hashes

2009-09-29 Thread Shawn H Corey
Soham Das wrote: How can I create a Hash of Hashes from two lists. Is it possible? I want the effective functionality to be served like this $ChildHash["Joe"]["21A"]="Sally" i.e Joe at 21A has a child called Sally. List1 here will be the name of Parents, Lis

Hash of Hashes

2009-09-29 Thread Soham Das
How can I create a Hash of Hashes from two lists. Is it possible? I want the effective functionality to be served like this $ChildHash["Joe"]["21A"]="Sally" i.e Joe at 21A has a child called Sally. List1 here will be the name of Parents, List2 here will con

Re: hash of hashes values and keys

2009-09-04 Thread Jim Gibson
At 1:56 PM -0700 9/4/09, Noah Garrett Wallach wrote: Hi there, I am trying to figure out how to use hash of hashes properly. can values and keys be at the same level? I am running in to troubles. Maybe values and keys cant be at the same level ? Values and keys exist as pairs within a

Re: hash of hashes values and keys

2009-09-04 Thread Uri Guttman
>>>>> "NGW" == Noah Garrett Wallach writes: NGW> I am trying to figure out how to use hash of hashes properly. can NGW> values and keys be at the same level? no. any level can have one key of a given string, that is how hashes are defined. if you need more t

hash of hashes values and keys

2009-09-04 Thread Noah Garrett Wallach
Hi there, I am trying to figure out how to use hash of hashes properly. can values and keys be at the same level? I am running in to troubles. Maybe values and keys cant be at the same level ? $policy{policy_statement}{$key} = 2; $policy{policy_statement

Re: hash of hashes question

2009-09-04 Thread Noah Garrett Wallach
Patrick Dupre wrote: On Fri, 4 Sep 2009, Noah Garrett Wallach wrote: Hi there, I am having some trouble understanding hash of hashes here. I want to find all the keys for %policy{'policy_statement'} for my $line (@lines) { for my $key ( keys %policy{'p

Re: hash of hashes question

2009-09-04 Thread Patrick Dupre
On Fri, 4 Sep 2009, Noah Garrett Wallach wrote: Hi there, I am having some trouble understanding hash of hashes here. I want to find all the keys for %policy{'policy_statement'} for my $line (@lines) { for my $key ( keys %policy{'policy_statement'} )

Re: hash of hashes question

2009-09-04 Thread Jim Gibson
At 11:02 AM -0700 9/4/09, Noah Garrett Wallach wrote: Hi there, I am having some trouble understanding hash of hashes here. I want to find all the keys for %policy{'policy_statement'} for my $line (@lines) { for my $key ( keys %policy{'policy_statement'}

hash of hashes question

2009-09-04 Thread Noah Garrett Wallach
Hi there, I am having some trouble understanding hash of hashes here. I want to find all the keys for %policy{'policy_statement'} for my $line (@lines) { for my $key ( keys %policy{'policy_statement'} ) { if ($line =~ /set\sprotocols\sbgp\sg

RE: Printing a hash of hashes of arrays

2009-08-28 Thread Wagner, David --- Senior Programmer Analyst --- CFS
> -Original Message- > From: Ian [mailto:pcs...@gmail.com] > Sent: Thursday, August 27, 2009 11:43 > To: beginners@perl.org > Subject: Printing a hash of hashes of arrays > > Pure beginners question. > > I'm creating a hash of arrays like this :

Re: Printing a hash of hashes of arrays

2009-08-27 Thread Ian
Thank you David, Jim, Uri.

Re: Printing a hash of hashes of arrays

2009-08-27 Thread Uri Guttman
> "I" == Ian writes: I> Pure beginners question. I> I'm creating a hash of arrays like this : I> $ihash{$3}{$1} = [...@itab]; I> For now I was able to get the data using Dumper but I need to create a I> "pretty" report. I> How do I loop over this hash/hash of arrays to print i

Re: Printing a hash of hashes of arrays

2009-08-27 Thread Jim Gibson
On 8/27/09 Thu Aug 27, 2009 10:42 AM, "Ian" scribbled: > Pure beginners question. > > I'm creating a hash of arrays like this : > > $ihash{$3}{$1} = [...@itab]; > > For now I was able to get the data using Dumper but I need to create a > "pretty" report. > > How do I loop over this hash/has

Printing a hash of hashes of arrays

2009-08-27 Thread Ian
Pure beginners question. I'm creating a hash of arrays like this : $ihash{$3}{$1} = [...@itab]; For now I was able to get the data using Dumper but I need to create a "pretty" report. How do I loop over this hash/hash of arrays to print it out? Thank you. -- Ian

Re: Hash of hashes?

2008-01-22 Thread John W. Krahn
Chas. Owens wrote: On Jan 21, 2008 4:30 PM, Kevin Viel <[EMAIL PROTECTED]> wrote: snip You placed another little gem in here for me to digest: $outer{$snp}{$_}++ for $genotype =~ /(.)/g; } I guess when I conceive of that by myself, I should move to the intermediate mailing list :) snip

Re: Hash of hashes?

2008-01-22 Thread Chas. Owens
On Jan 21, 2008 4:30 PM, Kevin Viel <[EMAIL PROTECTED]> wrote: snip > You placed another little gem in here for me to digest: > > > $outer{$snp}{$_}++ for $genotype =~ /(.)/g; } > > I guess when I conceive of that by myself, I should move to the intermediate > mailing list :) snip It could a

RE: Hash of hashes?

2008-01-22 Thread Kevin Viel
> -Original Message- > From: Chas. Owens [mailto:[EMAIL PROTECTED] > Sent: Monday, January 21, 2008 1:11 PM > To: Kevin Viel > Cc: beginners@perl.org > Subject: Re: Hash of hashes? > #! /usr/bin/perl > > use strict; > use warnings; > > use Dat

Re: Hash of hashes?

2008-01-21 Thread Rob Dixon
Chas. Owens wrote: On Jan 21, 2008 2:11 PM, Chas. Owens <[EMAIL PROTECTED]> wrote: snip snip So, if I understand correctly $data{$snp} is a value in a hash. That value is a scalar that happens, in this case, to be a reference to an anonymous hash? The key of this anonymous hash is $genotype?

Re: Hash of hashes?

2008-01-21 Thread Chas. Owens
On Jan 21, 2008 2:11 PM, Chas. Owens <[EMAIL PROTECTED]> wrote: snip > snip > > So, if I understand correctly $data{$snp} is a value in a hash. That value > > is a scalar that happens, in this case, to be a reference to an anonymous > > hash? The key of this anonymous hash is $genotype? It does

Re: Hash of hashes?

2008-01-21 Thread Chas. Owens
s %{$hashref}; When you want to iterate over all of the keys in a hash you can use the keys in a list context: for my $key (keys %hash) { } If it is a Hash of hashes you can just keep nesting (remembering to use %{}): for my $k1 (keys %hash) { for my $k2 (keys %{$hash{$k1}}) { for my

Re: Hash of hashes?

2008-01-21 Thread Tom Phoenix
On Jan 21, 2008 10:27 AM, Kevin Viel <[EMAIL PROTECTED]> wrote: > > $data{$snp}{$genotype}++ > > Is the semicolon unnecessary for this line? It's not the line that matters, so much as what's going on. The semicolon is used after most statements to indicate the end of the statement; but the co

RE: Hash of hashes?

2008-01-21 Thread Kevin Viel
> -Original Message- > From: Chas. Owens [mailto:[EMAIL PROTECTED] > Sent: Friday, January 18, 2008 9:07 PM > To: Kevin Viel > Cc: beginners@perl.org > Subject: Re: Hash of hashes? > > On Jan 18, 2008 6:06 PM, Kevin Viel <[EMAIL PROTECTED]> wrote: > &

Re: Hash of hashes?

2008-01-19 Thread [EMAIL PROTECTED]
On Jan 18, 11:06 pm, [EMAIL PROTECTED] (Kevin Viel) wrote: > This I cannot get my mind around... > > My data: > > SNP Genotype > 1 CC > 1 CT > 1 TT > 1 NN > > It seems to me that I need a hash of hashes. > > Inner hash: > > $

Re: Hash of hashes?

2008-01-18 Thread Chas. Owens
On Jan 18, 2008 6:06 PM, Kevin Viel <[EMAIL PROTECTED]> wrote: > This I cannot get my mind around... > > My data: > > SNP Genotype > 1 CC > 1 CT > 1 TT > 1 NN > > > It seems to me that I need a hash of hashes. > > Inner hash:

Hash of hashes?

2008-01-18 Thread Kevin Viel
This I cannot get my mind around... My data: SNP Genotype 1 CC 1 CT 1 TT 1 NN It seems to me that I need a hash of hashes. Inner hash: $inner{ $Genotype }++ ; Since the value of the out hash ( $outer{ $SNP } ) has to be a scalar, this scalar has to be a reference to

Re: hash of hashes & arrays

2006-03-04 Thread Hans Meier (John Doe)
regatta am Freitag, 3. März 2006 21.29: > Good morning/evening everyone, > > I have a hash of data , this hash is very big with dynamic elements > (strings, numbers, hashes, arrays) > > Here is an example > > $info{'system'}{'load'}{'1'} > $info{'system'}{'load'}{'5'} > $info{'system'}{'load'}{'15'

Re: hash of hashes & arrays

2006-03-03 Thread Jeff Pang
>The size and the data may get changed, so is there any function that >can help me to print all the %info data to be like this : > Is Data::Dumper fit for you? See 'perldoc Data::Dumper' please. -- Jeff Pang NetEase AntiSpam Team http://corp.netease.com -- To unsubscribe, e-mail: [EMAIL PRO

hash of hashes & arrays

2006-03-03 Thread regatta
Good morning/evening everyone, I have a hash of data , this hash is very big with dynamic elements (strings, numbers, hashes, arrays) Here is an example $info{'system'}{'load'}{'1'} $info{'system'}{'load'}{'5'} $info{'system'}{'load'}{'15'} $info{'system'}{'hostid'} $info{'system'}{'time'} $info

Re: Sorting a hash of hashes

2006-02-03 Thread John W. Krahn
variables $seconds, $minutes and $hours anywhere? > $timecomp = ($time - $nonewer); > > %tmp = (); > # setup temp hash > $count = 0; You are using a numerical index so you should probably use an Array of Hashes instead of a Hash of Hashe

RE: Sorting a hash of hashes

2006-02-02 Thread Wagner, David --- Senior Programmer Analyst --- WGO
Scott Palmer wrote: > I am attempting to sort by a field in a hash within a hash and I am > having a hard time finding the right direction. I want the print out > to sort from smallest to largest in size. Any help would be greatly > appreciated. > > Scott > > -

Sorting a hash of hashes

2006-02-02 Thread Scott Palmer
I am attempting to sort by a field in a hash within a hash and I am having a hard time finding the right direction. I want the print out to sort from smallest to largest in size. Any help would be greatly appreciated. Scott -- #!/usr/bin/perl # Set your s

Re: Sorting hash of hashes

2005-10-06 Thread Jeff 'japhy' Pinyan
On Oct 6, Rose, Jeff said: I have been trying to sort a hash but I cannot figure it out for the life of me I've fixed a bit of the formatting below... my %message = ( $messageid => { From=> $from, To => $to, To_Num => $num, Sub_IP => $ip, Subject => $subject,

Sorting hash of hashes

2005-10-06 Thread Rose, Jeff
I have been trying to sort a hash but I cannot figure it out for the life of me The hash is in the form: my %message { messageid { From=> To=> T

Re: keys of hash of hashes

2005-09-16 Thread Jeff 'japhy' Pinyan
On Sep 16, Brent Clark said: foreach my $fileName ( keys %$ref_allTariffData ){ print keys $ref_allTariffData{$fileName}; } The keys() function takes a hash. You used it properly the FIRST time, but not the second. And, $hash{$key} means that you have a hash called '%hash', where

Re: keys of hash of hashes

2005-09-16 Thread Jeff Pan
maybe u want this: foreach my $fileName ( keys %$ref_allTariffData ){ foreach my $name ( keys %{$ref_allTariffData->{$fileName}} ){ print $name,";"; } } On Fri, 16 Sep 2005 10:33:58 +0200, "Brent Clark" <[EMAIL PROTECTED]> said: > Hi list > > I hav

keys of hash of hashes

2005-09-16 Thread Brent Clark
Hi list I have a hash that im trying to get the keys. foreach my $fileName ( keys %$ref_allTariffData ){ print keys $ref_allTariffData{$fileName}; } My Data Dumper: $VAR1 = { 'sham02' => { 'Luxury' => 'LuxRm' }, 'kw

Re: efficiency of hash of hashes/lists

2005-05-24 Thread Dave Gray
> > # access test for 2d > > ($su, $ss) = times; > > for my $i (0 .. $hashsize-1) { > > $oned{$l1[$i]}{$l2[$i]}++ > > I think you should be operating on %twod here. LOL, thanks. Original poster take note: generating hashes..! base 0.03 0.00 0.03

Re: efficiency of hash of hashes/lists

2005-05-24 Thread Paul Johnson
On Tue, May 24, 2005 at 02:13:49PM -0400, Dave Gray wrote: > On 5/23/05, Peter Rabbitson <[EMAIL PROTECTED]> wrote: > > On Mon, May 23, 2005 at 01:40:08PM -0400, Zhenhai Duan wrote: > > > I tried hash (where the members of a group are joined with ":"), and hash > > > of hash. It happended that has

Re: efficiency of hash of hashes/lists

2005-05-24 Thread Philip M. Gollucci
Dave Gray wrote: On 5/23/05, Peter Rabbitson <[EMAIL PROTECTED]> wrote: On Mon, May 23, 2005 at 01:40:08PM -0400, Zhenhai Duan wrote: I tried hash (where the members of a group are joined with ":"), and hash of hash. It happended that hash of hash is slower than single hash. Hash: $gr

Re: efficiency of hash of hashes/lists

2005-05-24 Thread Dave Gray
On 5/23/05, Peter Rabbitson <[EMAIL PROTECTED]> wrote: > On Mon, May 23, 2005 at 01:40:08PM -0400, Zhenhai Duan wrote: > > I tried hash (where the members of a group are joined with ":"), and hash > > of hash. It happended that hash of hash is slower than single hash. > > > > Hash: > > $groups{$g1}

Re: efficiency of hash of hashes/lists

2005-05-23 Thread Peter Rabbitson
On Mon, May 23, 2005 at 01:40:08PM -0400, Zhenhai Duan wrote: > I tried hash (where the members of a group are joined with ":"), and hash > of hash. It happended that hash of hash is slower than single hash. > > Hash: > $groups{$g1} = "$member1:$member2"; > > > Hash of hash > $groups{$g1}{$memb

Re: efficiency of hash of hashes/lists

2005-05-23 Thread Zhenhai Duan
I tried hash (where the members of a group are joined with ":"), and hash of hash. It happended that hash of hash is slower than single hash. Hash: $groups{$g1} = "$member1:$member2"; Hash of hash $groups{$g1}{$member1} = 1; Method 1 is faster, even I need to do a split to get the members. -

RE: efficiency of hash of hashes/lists

2005-05-22 Thread Charles K. Clarkson
Zhenhai Duan wrote: : Can anyone give me some suggestions which one is better? Whichever is easiest to read is probably the better solution. Unless you are dealing with a finished program where you need additional speed, let readability be your guide. HTH, Charle

Re: efficiency of hash of hashes/lists

2005-05-22 Thread Jeff 'japhy' Pinyan
On May 22, Zhenhai Duan said: I am wondering if the performance (time efficiency) of hash of hash is bad. I has this impression from the code I developed. Basically my structure needs to hold the members of different groups. I have different choices: hash of hash $groups{$g1}{$member1} = 1; b

efficiency of hash of hashes/lists

2005-05-22 Thread Zhenhai Duan
Hi, I am wondering if the performance (time efficiency) of hash of hash is bad. I has this impression from the code I developed. Basically my structure needs to hold the members of different groups. I have different choices: hash: $groups{$g1} = "$member1:$member2:$member3..."; but everytime

Re: Copying a hash-of-hashes

2004-12-31 Thread Octavian Rasnita
What's the difference between using the Clone module and simply assigning $ref1 = $ref2? Thanks. Teddy - Original Message - From: "zentara" <[EMAIL PROTECTED]> To: Sent: Thursday, December 30, 2004 3:45 PM Subject: Re: Copying a hash-of-hashes On Wed, 29 De

Re: Copying a hash-of-hashes

2004-12-30 Thread Alfred Vahau
Hi, The three CPAN modules suitable for copying data structures are: Storable, Data::Dumper and FreezeThaw. Of these, Storable offers the dclone method which addresses the problem on hand. use Storable qw(dclone); $ref2 = dclone ($ref1); The method works on references to scalars, arrays and hashe

Copying a hash-of-hashes

2004-12-30 Thread Bakken, Luke
> Hello List, > To explain the problem I am having, I wrote a simple snipet > that doesn't do > anything meaningful other than illustrating the behaviour I > want to avoid: > > my %hoh = ( > 1 => { > a => 5, b => 5 > }, > > 2 => 5 >

  1   2   >