> 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
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
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
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
> -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
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
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
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
>
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
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
> "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
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
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
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
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
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
> -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
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?
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
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
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
> -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:
> &
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
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
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'
>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
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
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
>
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
>
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
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
>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
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
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.
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
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
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
> > # 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 }'
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
39 matches
Mail list logo