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

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 it > throws an error which sta

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 >>> >>> $ChildHash["Joe"]["21A"]="Sally" >>> >>> i.e Joe at 21

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" >> >> i.e Joe at 21A has a child called Sally. List1 here will be the name of >

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, List2 here will contain the house numbe

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 has

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 than one thing, you need to make an

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{'policy_statement'} ) { Ch

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'} ) { Check if $keys is correc

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'} ) { %policy is a hash

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
On Jan 21, 2008 1:27 PM, Kevin Viel <[EMAIL PROTECTED]> wrote: snip > > while () { > > my ($snp, $genotype) = split; > > $data{$snp}{$genotype}++ > > } snip > > $data{$snp}{$genotype}++ > > Is the semicolon unnecessary for this line? snip The semi-colon in Perl is a statement separator

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: > > $inner{ $Genotype }++ ; > > Since the value of the

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: > > $inner{ $Genotype }++ ; > > Since the value

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

Re: Hash of Hashes of Arrays?

2003-01-26 Thread Jenda Krynicky
From: Pete Emerson <[EMAIL PROTECTED]> > push @{$hash{$city}{$station}}, $add1; > push @{$hash{$city}{$station}}, $add2; > push @{$hash{$city}{$station}}, $state; > push @{$hash{$city}{$station}}, $zip; > push @{$hash{$city}{$station}}, $phone; You can push several items into an array at once: pu

Re: Hash of Hashes of Arrays?

2003-01-24 Thread Glenn Tremblay
On Fri, 24 Jan 2003, david wrote: > Glenn Tremblay wrote: > > > > Actually, the funny part of all this is that every station will be in the > > same state. I need to include the state information regardless. > > > > The output needs to allow me to loop through each city, somehow, and print >

Re: Hash of Hashes of Arrays?

2003-01-24 Thread Glenn Tremblay
On Fri, 24 Jan 2003, david wrote: > Glenn Tremblay wrote: > > > > > This is what I need to do: > > I believe I need a hash of hashes of arrays... > > I am creating output in the format of inspection pages which list all > > inspection stations in each town (some towns have only one, others have >

Re: Hash of Hashes of Arrays?

2003-01-24 Thread david
Glenn Tremblay wrote: > > This is what I need to do: > I believe I need a hash of hashes of arrays... > I am creating output in the format of inspection pages which list all > inspection stations in each town (some towns have only one, others have > several). > I need to group the lines (of addres

Re: Hash of Hashes of Arrays?

2003-01-24 Thread Manideepa Bhowmik
Hello folks, I am having a problem of embedding the html tag http://www.cnn.com >Click here in a perl script. Could someone please help . Thanks. Deepa >>> <[EMAIL PROTECTED]> 01/24/03 01:01PM >>> >I have a list of inspection stations in a data file which is >comma-separated. It contains the fo

Re: Hash of Hashes of Arrays?

2003-01-24 Thread Peter_Farrar
>I have a list of inspection stations in a data file which is >comma-separated. It contains the following data, in order: >Station Name, Address 1, Address Line 2, City, State, Zip, Phone Number > >I need to group the lines (of address information) by city and get a count >of the number of statio

Re: Hash of Hashes of Arrays?

2003-01-24 Thread Pete Emerson
I'd be tempted to use a hash of hash of hashes, storing it like this: $hash{$city}{$station}{add1}=$address1 $hash{$city}{$station}{add2}=$address2 $hash{$city}{$station}{state}=$state $hash{$city}{$station}{zip}=$zip $hash{$city}{$station}{phone}=$phone So my loop would look like this: foreach my

Re: Hash of Hashes woes...

2002-09-05 Thread Dharmendra Rai
Pass the keys($dom,$eng...) by ref. All you are doing is passing the array by reference which has a copy of your keys. - Get a bigger mailbox -- choose a size that fits your needs.

Re: Hash of Hashes woes...

2002-09-04 Thread Greg Oliver
On Wed, 04 Sep 2002 15:21:37 -0700 "John W. Krahn" <[EMAIL PROTECTED]> wrote: > You should probably just return $newdata and assign it directly in the > foreach loop. > John > -- True, but the nature of the threads in this one, I do not get the result. One line beow in the example is: $pool->j

Re: Hash of Hashes woes...

2002-09-04 Thread John W. Krahn
Greg Oliver wrote: > > Hi, Hello, > I am writing a script that initializes a %HoHoH while iterating > through several items. This works correctly, and also retrieving > the keys/values works correctly. I then call a subroutine that > retrieves data and is SUPPOSED to update that same hash wit

Re: Hash of Hashes woes...

2002-09-04 Thread david
Greg Oliver wrote: > %Results = ( > $cty => { $dom => { $eng => "value"}} ); you might want to consider: my $Results; $Results->{$cty}->{$dom}->{$eng} = "value"; as that seem to be more readable. :-) > > I agree, but it isn't!!! The only other thing that could be it is th

Re: Hash of Hashes woes...

2002-09-04 Thread Greg Oliver
> > # Main > > my $Results; > > this only declare a $Results scalar Sorry typo for the email! it is %Results > > # Initialized with 3 for every value > > # $Results{ $cty }{ $dom }{ $eng } = "3"; > > here, you are trying to use a %Results hash from $Results{ $cty }. > the '{ $dom }{ $eng }'

Re: Hash of Hashes woes...

2002-09-04 Thread david
Greg Oliver wrote: > Example: > > # Main > my $Results; this only declare a $Results scalar > > # Initialized with 3 for every value > # $Results{ $cty }{ $dom }{ $eng } = "3"; here, you are trying to use a %Results hash from $Results{ $cty }. the '{ $dom }{ $eng }' portion does create a has