Re: Array of Hashes

2012-04-13 Thread Paul.G
Thanks for your help, I will look carefully at both of your comments. cheers From: John W. Krahn jwkr...@shaw.ca To: Perl Beginners beginners@perl.org Sent: Friday, 13 April 2012 6:08 AM Subject: Re: Array of Hashes Rob Dixon wrote: Hi Paul and welcome

Array of Hashes

2012-04-12 Thread Paul.G
Hi All New to this group, so hello to everybody. I am currently working on creating a Array of Hashes, note it is a work in progress. I appear to be getting some corruption when inputting data with the pvdisplay, I can't see why this is the case. I have put some print statements to see where I

Re: Array of Hashes - problem solved

2012-04-12 Thread Paul.G
beginners@perl.org Sent: Thursday, 12 April 2012 9:48 PM Subject: Array of Hashes Hi All New to this group, so hello to everybody. I am currently working on creating a Array of Hashes, note it is a work in progress. I appear to be getting some corruption when inputting data with the pvdisplay, I

Re: Array of Hashes

2012-04-12 Thread Rob Dixon
On 12/04/2012 12:48, Paul.G wrote: Hi All New to this group, so hello to everybody. I am currently working on creating a Array of Hashes, note it is a work in progress. I appear to be getting some corruption when inputting data with the pvdisplay, I can't see why this is the case. I have put

Re: Array of Hashes

2012-04-12 Thread John W. Krahn
Rob Dixon wrote: Hi Paul and welcome to the list. I can see a few things wrong with your code, but I have only a Windows machine so cannot test any changes I am suggestion so please beware. The reason you get the marked line in your output is because that is what you have written. This loop

Foreach with array of hashes

2008-07-19 Thread Bobby Jafari
Hi all, I am getting a syntax error with the following code: Line 10: @snmpSessions = (%snmpSession1, %snmpSession2); Line 11: foreach %snmpSession (@snmpSessions) Line 12: { Line 13:# The following is call to my own subroutine that has been tested and it works (:-) Line 14:

Re: Foreach with array of hashes

2008-07-19 Thread Amit Saxena
On Sat, Jul 19, 2008 at 2:45 PM, Bobby Jafari [EMAIL PROTECTED] wrote: Hi all, I am getting a syntax error with the following code: Line 10: @snmpSessions = (%snmpSession1, %snmpSession2); Line 11: foreach %snmpSession (@snmpSessions) Line 12: { Line 13:# The following is call to

RE: Foreach with array of hashes

2008-07-19 Thread Bobby Jafari
Thanks heaps. Problem solved. code changed to Line 10: @snmpS = (\%snmpSession1, \%snmpSession2); Line 11: foreach $snmpS (@snmpSessions) Line 12: { Line 13:ethernetGlobalMode ($snmpS); Line 14: }

Re: Counting keys in an array of hashes?

2008-02-22 Thread jamesdon
On Feb 21, 9:46 am, [EMAIL PROTECTED] (Chas. Owens) wrote: On Wed, Feb 20, 2008 at 11:03 PM, [EMAIL PROTECTED] wrote: snip Oh - I wanted to eliminate all members of the array that had more than 10 instances of the same port. I was hoping that you could do something like count keys

Re: Counting keys in an array of hashes?

2008-02-21 Thread jamesdon
Hi, thank you all for your input - I managed to get what I wanted done. Sorry I was not very clear on the issue, but it helped to write it out. Jim -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: Counting keys in an array of hashes?

2008-02-21 Thread jamesdon
I have a feeling that I am going about this in the wrong way. Can I use hashes in a better way to sort the data based on the keys? Better yet, can I evaluate the number of keys that match each other? I don't understand what that means. John Oh - I wanted to eliminate all members of the

Re: Counting keys in an array of hashes?

2008-02-21 Thread jamesdon
On Feb 20, 10:26 pm, [EMAIL PROTECTED] wrote: Hi, thank you all for your input - I managed to get what I wanted done. Sorry I was not very clear on the issue, but it helped to write it out. Jim Please ignore this post ^, I do not have a end solution yet. -- To unsubscribe, e-mail: [EMAIL

Re: Counting keys in an array of hashes?

2008-02-21 Thread Chas. Owens
On Wed, Feb 20, 2008 at 11:03 PM, [EMAIL PROTECTED] wrote: snip Oh - I wanted to eliminate all members of the array that had more than 10 instances of the same port. I was hoping that you could do something like count keys where port = gi1/1/49. After knowing how many gi1/1/49 there

Counting keys in an array of hashes?

2008-02-20 Thread jamesdon
I am reading in a file, building an array of information that I need to evaluate: while (FILE) { if ($_ =~ m/stuff/) { push(@data, {'vlan' = $vlan, 'host' = $host, 'mac' = $mac, 'port' = $port}); } } Small sample of @data: vlan hostmacport 13 switch-1

Re: Counting keys in an array of hashes?

2008-02-20 Thread John W. Krahn
[EMAIL PROTECTED] wrote: I am reading in a file, building an array of information that I need to evaluate: while (FILE) { if ($_ =~ m/stuff/) { push(@data, {'vlan' = $vlan, 'host' = $host, 'mac' = $mac, 'port' = $port}); } } Small sample of @data: vlan hostmac

Re: Counting keys in an array of hashes?

2008-02-20 Thread Chas. Owens
On Feb 19, 2008 11:12 PM, [EMAIL PROTECTED] wrote: I am reading in a file, building an array of information that I need to evaluate: while (FILE) { if ($_ =~ m/stuff/) { push(@data, {'vlan' = $vlan, 'host' = $host, 'mac' = $mac, 'port' = $port}); } } Small sample of @data: vlan

Re: packing an array of hashes

2007-08-08 Thread Paul Lalli
On Aug 7, 7:47 pm, [EMAIL PROTECTED] (Chris Cosner) wrote: I've re-read perlref and have been trying to tease an answer out of the Perl Cookbook. If you put a hash reference into an array push @array, \%hash; you do not store any actual hash data in the array. So if you change the

packing an array of hashes

2007-08-07 Thread Chris Cosner
I've re-read perlref and have been trying to tease an answer out of the Perl Cookbook. If you put a hash reference into an array push @array, \%hash; you do not store any actual hash data in the array. So if you change the hash, then later pull the hash reference from the array and access

Re: packing an array of hashes

2007-08-07 Thread Mr. Shawn H. Corey
Chris Cosner wrote: If you put a hash reference into an array push @array, \%hash; you do not store any actual hash data in the array. So if you change the hash, then later pull the hash reference from the array and access it, you get changed data. push @array, { %hash }; This creates an

Re: packing an array of hashes

2007-08-07 Thread rcook
I've re-read perlref and have been trying to tease an answer out of the Perl Cookbook. If you put a hash reference into an array push @array, \%hash; you do not store any actual hash data in the array. So if you change the hash, then later pull the hash reference from the array and

Re: packing an array of hashes

2007-08-07 Thread Chris Cosner
Aha. Many thanks. Now I'm on the right track (see Anonymous Data in the Perl Cookbook, ch. 11). Mr. Shawn H. Corey wrote: Chris Cosner wrote: If you put a hash reference into an array push @array, \%hash; you do not store any actual hash data in the array. So if you change the hash, then

Accessing hash within an array of hashes

2007-08-07 Thread Charles J Gillan
I have a problem with extracting an individual hash from an array of hashes. I can't work out, or find elsewhere, the syntax for this. Code as follows: devices_array_oH is set up as array of hashes I want to loop over all hashes in the array and to print the key value pairs for each hash

Re: Accessing hash within an array of hashes

2007-08-07 Thread Paul Lalli
On Aug 7, 7:59 am, [EMAIL PROTECTED] (Charles J Gillan) wrote: I have a problem with extracting an individual hash from an array of hashes. I can't work out, or find elsewhere, the syntax for this. The syntax is found in perldoc perlref perldoc perlreftut perldoc perllol and perldoc perldsc

Re: Accessing hash within an array of hashes

2007-08-07 Thread Mr. Shawn H. Corey
Paul Lalli wrote: I would have written the program like this: my $itemp = 1; foreach my $device_hash_ref (@devices_array_oH) { print Details of device $itemp: ; print \n\n; foreach my $key (keys %{$device_hash_ref}) { print ( $key \t $device_hash{$key} \n);

Re: Accessing hash within an array of hashes

2007-08-07 Thread Paul Lalli
On Aug 7, 8:29 am, [EMAIL PROTECTED] (Mr. Shawn H. Corey) wrote: Paul Lalli wrote: foreach my $key (keys %{$device_hash_ref}) { print ( $key \t $device_hash{$key} \n); print ( $key \t $device_hash_ref-{$key} \n); Whoops! Quite correct. Thanks for catching

Re: reference to array of hashes in OOP

2007-07-12 Thread Inventor
On Jul 11, 9:04 pm, [EMAIL PROTECTED] (Paul Lalli) wrote: If you have access to the server logs, check them. If not, add this line to the top of your program, right under use strict and use warnings: use CGI::Carp qw/fatalsToBrowser/; Paul Lalli Thanks Paul, it's nice to have error

reference to array of hashes in OOP

2007-07-11 Thread Inventor
Hi, I would like to make a perl module with an array of hashes as the data structure, but I am having trouble with the references. I have declared the data structure in the constructor as follows: my $self = ({}); and blessed it with: bless ($self, $class_name); but when I try

Re: reference to array of hashes in OOP

2007-07-11 Thread Mr. Shawn H. Corey
Inventor wrote: Hi, I would like to make a perl module with an array of hashes as the data structure, but I am having trouble with the references. I have declared the data structure in the constructor as follows: my $self = ({}); my $self = []; and blessed it with: bless

Re: reference to array of hashes in OOP

2007-07-11 Thread Paul Lalli
On Jul 11, 3:33 pm, [EMAIL PROTECTED] (Inventor) wrote: the program gets a run-time error, and I don't know which error message it is because the module is used in a CGI program and I don't know how to get at the error messages. If you have access to the server logs, check them. If not, add

Re: accesing a hash of an array of hashes

2007-05-29 Thread Jenda Krynicky
From: pauld [EMAIL PROTECTED] ive read a load of data in from a CSV file with Text::CSV and ended up with a hash (%hash) where the keys are the column labels. my @headings=split(/,/,$rows[0]) and then for (my $j=1;$j$#rows;$j++) { my $status = $csv-parse ($rows[$j]); # parse a CSV

Re: accesing a hash of an array of hashes

2007-05-28 Thread pauld
thanks for the help - im looking up hash slices - but id like to get something that works and then i can add new ideas etc so im going to leave it as it for the time being. Data::Dumper has helped sort out where an error is coming #!/usr/bin/perl -w use strict; use warnings; open O, $file or

Re: accesing a hash of an array of hashes

2007-05-28 Thread Paul Lalli
On May 27, 4:37 pm, [EMAIL PROTECTED] (Pauld) wrote: thanks for the help - im looking up hash slices - perldoc perldata Entire arrays (and slices of arrays and hashes) are denoted by '@', which works much like the word these or those does in English, in that it indicates multiple

accesing a hash of an array of hashes

2007-05-26 Thread pauld
ive read a load of data in from a CSV file with Text::CSV and ended up with a hash (%hash) where the keys are the column labels. my @headings=split(/,/,$rows[0]) and then for (my $j=1;$j$#rows;$j++) { my $status = $csv-parse ($rows[$j]); # parse a CSV string into fields my @columns =

Re: accesing a hash of an array of hashes

2007-05-26 Thread Paul Lalli
On May 26, 8:17 am, [EMAIL PROTECTED] (Pauld) wrote: ive read a load of data in from a CSV file with Text::CSV and ended up with a hash (%hash) where the keys are the column labels. my @headings=split(/,/,$rows[0]) You're use()'ing Text::CSV, but you're not actually using Text::CSV. Why?

Re: accesing a hash of an array of hashes

2007-05-26 Thread yaron
a hash of an array of hashes ive read a load of data in from a CSV file with Text::CSV and ended up with a hash (%hash) where the keys are the column labels. my @headings=split(/,/,$rows[0]) and then for (my $j=1;$j$#rows;$j++) { my $status = $csv-parse ($rows[$j]); # parse a CSV string

Re: accesing a hash of an array of hashes

2007-05-26 Thread yaron
] To: pauld [EMAIL PROTECTED] Cc: beginners beginners@perl.org Sent: 19:47:38 (GMT+0200) Africa/Harare שבת 26 מאי 2007 Subject: Re: accesing a hash of an array of hashes Hi, To access element of a given DATE (sat ... date_inp) from Hofdates you can do the following: my $date_inp = ... ; die

Re: accesing a hash of an array of hashes

2007-05-26 Thread Mumia W.
On 05/26/2007 07:17 AM, pauld wrote: ive read a load of data in from a CSV file with Text::CSV and ended up with a hash (%hash) where the keys are the column labels. my @headings=split(/,/,$rows[0]) and then for (my $j=1;$j$#rows;$j++) { my $status = $csv-parse ($rows[$j]); # parse a CSV

Re: accesing a hash of an array of hashes

2007-05-26 Thread Paul Lalli
On May 26, 1:51 pm, [EMAIL PROTECTED] (Mumia W.) wrote: On 05/26/2007 07:17 AM, pauld wrote: ive read a load of data in from a CSV file with Text::CSV and ended up with a hash (%hash) where the keys are the column labels. my @headings=split(/,/,$rows[0]) and then for (my

accessing an array of hashes from another namespace

2006-08-21 Thread Andy Greenwood
I have a program which I am working on which has several different packages. One of these packages, FluxDB.pm, creates an array of hashes called @users. Each element is a hash containing (among other things) username and uid (primary key from the DB this is generated out of). In another package

Re: accessing an array of hashes from another namespace

2006-08-21 Thread Tom Phoenix
On 8/21/06, Andy Greenwood [EMAIL PROTECTED] wrote: I have a program which I am working on which has several different packages. One of these packages, FluxDB.pm, creates an array of hashes called @users. Each element is a hash containing (among other things) username and uid (primary key from

Creating an array of hashes from a database while preserving order

2006-07-20 Thread Derek Ash
I am creating a phone directory and would like to display the entire contents of the database ordered by last name utilizing the HTML:Template module. I am not sure the code that I have so far will work as I have planned as this is my first time ever using an array of hashes. How can I be sure

looping over an array of hashes

2006-04-28 Thread Graeme McLaren
Hi all, I need to loop over an array of hashes and assign a new hashref if a condition is met: I have a scalar which contains an array of hashes: $locations = [ { 'location_name' = 'Fionas House', 'location_id' = '0027

Re: looping over an array of hashes

2006-04-28 Thread Mr. Shawn H. Corey
On Fri, 2006-28-04 at 15:40 +0100, Graeme McLaren wrote: Hi all, I need to loop over an array of hashes and assign a new hashref if a condition is met: I have a scalar which contains an array of hashes: $locations = [ { 'location_name' = 'Fionas House

Array of hashes

2006-01-16 Thread balan.ranganathan
Hi All Can anyone tell me whether there is any way for declaring an array of hashes similar to creating array of structure variables in C programming? Thanks Best regards Bala The information contained in this electronic message and any attachments to this message are intended

Re: Array of hashes

2006-01-16 Thread Shawn Corey
[EMAIL PROTECTED] wrote: Hi All Can anyone tell me whether there is any way for declaring an array of hashes similar to creating array of structure variables in C programming? There is a module, Class::Struct, that might be what you want. See `perldoc Class:Struct`. However, I would

Looping over an array of hashes problem

2005-09-08 Thread Graeme McLaren
Morning all, I have a problem that I can't see a way around. Basically I have an array of hashes and I want to get the key and value of each hash but with the following code I'm getting: Type of arg 1 to keys must be hash (not array element) at /usr/lib/perl5/vendor_perl/Purchaser/Common.pm

Re: Looping over an array of hashes problem

2005-09-08 Thread Jeff Pan
an array of hashes and I want to get the key and value of each hash but with the following code I'm getting: Type of arg 1 to keys must be hash (not array element) at /usr/lib/perl5/vendor_perl/Purchaser/Common.pm line 477, near ]) #code: foreach my $key (keys $AoH[$map_loop{$i

array of hashes of arrays...

2005-08-16 Thread Ryan Perry
How can I do this correctly? foreach my $col (@columns) { my %{$col} = ( string = $col, number = [EMAIL PROTECTED] ); push (@graph, \%{$col}); } -- To unsubscribe, e-mail: [EMAIL PROTECTED] For

RE: array of hashes of arrays...

2005-08-16 Thread Charles K. Clarkson
Ryan Perry mailto:[EMAIL PROTECTED] wrote: : How can I do this correctly? : : : foreach my $col (@columns) { :my %{$col} = ( : string = $col, : number = [EMAIL PROTECTED] : ); :push

Re: array of hashes of arrays...

2005-08-16 Thread Daniel Mueller
On Monday 15 August 2005 22.47, Ryan Perry wrote: How can I do this correctly? foreach my $col (@columns) { my %{$col} = ( string = $col, number = [EMAIL PROTECTED] ); push (@graph,

array of hashes of arrays...

2005-08-15 Thread The Ghost
How can I do this correctly? foreach my $col (@columns) { my %{$col} = ( # -- I have a problem here, I want the hash to be named whatever $col is string = $col, number = [EMAIL PROTECTED] );

Re: array of hashes of arrays...

2005-08-15 Thread Peter Rabbitson
On Mon, Aug 15, 2005 at 04:08:22PM -0500, The Ghost wrote: How can I do this correctly? foreach my $col (@columns) { my %{$col} = ( # -- I have a problem here, I want the hash to be named whatever $col is string = $col,

Re: array of hashes of arrays...

2005-08-15 Thread Philip M. Gollucci
The Ghost wrote: How can I do this correctly? foreach my $col (@columns) { my %{$col} = ( # -- I have a problem here, I want the hash to be named whatever $col is string = $col, number = [EMAIL PROTECTED]

Anonymous array of hashes question

2005-08-04 Thread jason_normandin
Hello I have a situation where I build an anonymous array of hashes for some requests and responses found in a file (there can be multiple requests and responses). It works very nicely and tracks all of the responses and requests from an ip to another IP address. Here is my code: my $time=$1

Anonymous array of hashes question

2005-08-04 Thread Jason Normandin
Hello I have a situation where I build an anonymous array of hashes for some requests and responses found in a file (there can be multiple requests and responses). It works very nicely and tracks all of the responses and requests from an ip to another IP address. Here is my code: my $time=$1

Re: Anonymous array of hashes question

2005-08-04 Thread Philipp Traeder
On Friday 05 August 2005 01:37, Jason Normandin wrote: [..] if ($protocol =~ /PING REQUEST/) { push @{$pingRequests{$destination}}, { time = $time, sequenceNumber=$sequenceNumber }; } elsif ($protocol =~ /PING RESPONSE/) { push

Re: Anonymous array of hashes question

2005-08-04 Thread John W. Krahn
Jason Normandin wrote: Hello Hello, I have a situation where I build an anonymous array of hashes for some requests and responses found in a file (there can be multiple requests and responses). It works very nicely and tracks all of the responses and requests from an ip to another IP

Array of hashes

2005-07-13 Thread The Ghost
How can I get the information out of the hashes? sub somthing { while (my $ref = $sth-fetchrow_hashref()) { foreach my $col (keys %{$ref}) { $results[$x]{$col}=$ref-{$col}; } $x++;} return (@results); } Then later: (I don't understand this part) foreach my

Re: Array of hashes

2005-07-13 Thread John W. Krahn
The Ghost wrote: How can I get the information out of the hashes? sub somthing { while (my $ref = $sth-fetchrow_hashref()) { foreach my $col (keys %{$ref}) { $results[$x]{$col}=$ref-{$col}; } $x++;} return (@results); } Then later: (I don't understand this part)

Re: Array of hashes

2005-07-13 Thread Jeff 'japhy' Pinyan
On Jul 13, The Ghost said: foreach my $col (keys %{$ref}) { $results[$x]{$col}=$ref-{$col}; } $x++;} The @results array holds hash references... foreach my $result (@results) { foreach my $key (keys {$results[$x]}) { Here you want to do: foreach my $key

Re: Array of hashes

2005-07-13 Thread Scott R. Godin
Jeff 'japhy' Pinyan wrote: Here you want to do: foreach my $key (keys %$result) { since each element in @results is a hash-ref, and $result is an element from @results, you need to gets its keys. Since $result is a hash reference, you need to write %$result to get at the hash.

Question: Array of Hashes

2005-03-31 Thread Olivier, Wim W
Hi all, I have the following code below which I need to modify a bit. The script currently lists the key/value pairs for all processes in the system. What I need to achieve is for it to only list the key/value pairs for processes of which the Description key is of a certain ASCII value, say

Re: Question: Array of Hashes

2005-03-31 Thread Offer Kaye
On Thu, 31 Mar 2005 14:40:47 +0200, Olivier, Wim W wrote: Hi all, I have the following code below which I need to modify a bit. The script currently lists the key/value pairs for all processes in the system. What I need to achieve is for it to only list the key/value pairs for processes

RE: Question: Array of Hashes

2005-03-31 Thread Olivier, Wim W
Thanks Offer! It's working! Wim -Original Message- From: Offer Kaye [mailto:[EMAIL PROTECTED] Sent: 31 March 2005 02:55 PM To: Perl Beginners Subject: Re: Question: Array of Hashes On Thu, 31 Mar 2005 14:40:47 +0200, Olivier, Wim W wrote: Hi all, I have the following code below

array of hashes looping prob

2004-10-04 Thread Graeme McLaren
Hey all I'm stuck looping through an array of hashes, here is what I have: ## for my $a (@result){ for my $h (keys %$a){ $tst = $h-{$a}; } } ## @result contains a hashes, I can die it out ok... there is something wrong when I try looping

RE: array of hashes looping prob

2004-10-04 Thread Graeme McLaren
Ok everyone I got it: for my $a (@result){ for my $h (keys %$a){ print $h = $a-{$h} BRBRBR; } } Cheers, G :) From: Graeme McLaren [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: array of hashes looping prob Date: Mon, 04 Oct 2004 10:27:37 +0100 MIME-Version: 1.0 X-Originating-IP

RE: array of hashes looping prob

2004-10-04 Thread Charles K. Clarkson
From: Graeme McLaren mailto:[EMAIL PROTECTED] wrote: : Ok everyone I got it: : : for my $a (@result){ : : for my $h (keys %$a){ : : print $h = $a-{$h} BRBRBR; : } : } Avoid using $a and $b as variables. They are used by 'sort' and treated special by perl. Use descriptive

dereferencing array of hashes in a Tk widget

2004-09-13 Thread Michael Ragsdale
the database, I'm creating an Array of Hashes and displaying the data. The pertinent code follows: while (@row = $sth-fetchrow_array()) { $count ++; $id = $row[0]; $AoH[$count]{id} = $row[0]; $AoH[$count]{transstatus} = $row[7]; my $b1 = $f1-Button(-text = 'Update', -command

RE: Sorting an array of hashes

2004-08-06 Thread Chris Mortimore
-Original Message- From: Chris Mortimore [mailto:[EMAIL PROTECTED] Sent: Thursday, August 05, 2004 5:19 PM To: [EMAIL PROTECTED] Subject: Sorting an array of hashes I want to sort an AoH. Not each hash by its keys, but the array by the value of one of the keys in each hash. I know how

Sorting an array of hashes

2004-08-05 Thread Chris Mortimore
I want to sort an AoH. Not each hash by its keys, but the array by the value of one of the keys in each hash. I know how to sort a simple array. I know how to sort a hash by the keys. Could someone kindly point me to the documentation on sorting arrays of hashes? Thank you! Chris. - -

Re: Sorting an array of hashes

2004-08-05 Thread Gunnar Hjalmarsson
Chris Mortimore wrote: I want to sort an AoH. Not each hash by its keys, but the array by the value of one of the keys in each hash. The value of one of the keys? If you don't know *which* key in respective hash, this appears to be pretty tricky... -- Gunnar Hjalmarsson Email:

RE: Sorting an array of hashes

2004-08-05 Thread Chris Mortimore
://www.gunnar.cc/cgi-bin/contact.pl -- Of course I know _which_ key. Each hash has a key date_tm, I want to sort all the hashes in the array by their date_tm value which is in the format: mmdddhhmm. Chris. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL

RE: Sorting an array of hashes

2004-08-05 Thread Chris Devers
, this appears to be pretty tricky... Of course I know _which_ key. Each hash has a key date_tm, I want to sort all the hashes in the array by their date_tm value which is in the format: mmdddhhmm. Don't you think it might have been constructive to mention this the first time around? Can you please

RE: Sorting an array of hashes

2004-08-05 Thread Moon, John
-Original Message- From: Chris Mortimore [mailto:[EMAIL PROTECTED] Sent: Thursday, August 05, 2004 5:19 PM To: [EMAIL PROTECTED] Subject: Sorting an array of hashes I want to sort an AoH. Not each hash by its keys, but the array by the value of one of the keys in each hash. I know how

Re: Sorting an array of hashes

2004-08-05 Thread Randy W. Sims
On 8/5/2004 5:18 PM, Chris Mortimore wrote: I want to sort an AoH. Not each hash by its keys, but the array by the value of one of the keys in each hash. I know how to sort a simple array. I know how to sort a hash by the keys. Could someone kindly point me to the documentation on sorting arrays

Re: Sorting an array of hashes

2004-08-05 Thread Gunnar Hjalmarsson
... Of course I know _which_ key. Each hash has a key date_tm, I want to sort all the hashes in the array by their date_tm value which is in the format: mmdddhhmm. Aha, the keys have the same name.. Good! Then Randy's suggested code should do. As regards documentation, besides perldoc -f sort

How to explicitly declare an array of hashes?

2004-02-08 Thread Richard Heintze
Is there a way I can explictly declare that each array cell contains a hash? Here is the only way I know to do it: my @PCEs=[]; while ($Data-FetchRow()) { my %dh = $Data-DataHash(); $PCEs[$cn]{$dh{id}} = $dh{ridPCE}; } This my declaration only says that it is an array, not an array

Re: How to explicitly declare an array of hashes?

2004-02-08 Thread Wiggins d'Anconia
that it is an array, not an array of hashes. Can I improve upon this? Why would you want to declare this? Since the anonymous hashes spring into existence automatically, no declaration is necessary. To access an element of your referenced hash, you have to add another scalar symbol like this: $$PCEs

Re: How to explicitly declare an array of hashes?

2004-02-08 Thread Wiggins d'Anconia
the value you are assigning which will cause your array to have one value, the last. If you are changing $cn in the DataHash method you shouldn't be and have broken the encapsulation, but that is a design issue. } This my declaration only says that it is an array, not an array of hashes. Can I

Re: How to explicitly declare an array of hashes?

2004-02-08 Thread Jan Eden
Wiggins d'Anconia wrote: Jan Eden wrote: $$PCEs[$cn]{$dh{id}} ... Adding an extra $ here causes Perl to look for $PCEs a scalar, which doesn't exist rather than dereference the PCEs array. Ok, I thought of a construction like $ {$PCEs[$cn]} {$dh{id}} ... This should be equivalent to the

Printing Array of Hashes

2003-12-23 Thread William Martell
Hi John, I received your code. Thanks. I would like to know how to check the values of the keys in the hash. I checked the Perl cookbook and It showed me how to get the key value pairs and print them, but I am not familiar with populating an array with a hash, or how to dynamically print the

Re: Printing Array of Hashes

2003-12-23 Thread Roberto Álamos Moreno
Hi William, This is very simple. The key function will do the work as in this example: my %hash; my @keys; my @values; $hash{key1} = value1; $hash{key2} = value2; foreach my $key (keys %hash) { push(@keys,$key); push(@values,$hash{$key}); } After the execution of this script

Re: Printing Array of Hashes

2003-12-23 Thread John W. Krahn
with a hash, or how to dynamically print the values out. I was only using an array of hashes because you used that in your code. If you are having problems with Perl's data structures have a look at the fine documentation: perldoc perldata perldoc perldsc perldoc perllol A handy module for displaying

Re: Printing Array of Hashes

2003-12-23 Thread William Martell
Terrific. Thank you. Thank you. Thank you. - Original Message - From: John W. Krahn [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Tuesday, December 23, 2003 4:19 PM Subject: Re: Printing Array of Hashes William Martell wrote: Hi John, Hello, I received your code. Thanks

problem using array of hashes and hash of hashes

2002-10-21 Thread naveen prabhakar
Hi experts,help!! I am reading data from a text file and storing the data in an array of hashes and hash of hashes.I dont know how and where I need to pass the reference into the array and hash and dereference it. The purpose of the code is to read data by column names and compare each record

Array of Hashes

2002-09-18 Thread Simon Tomlinson
Hi I want to put a hash into each element of an array. I do it like the following bit of code. When I iterate round my hash before putting it in the array of the hash values/keys are there. However, when I iterate through the hash after putting it in the array all i get is '4/8' as the

RE: Array of Hashes

2002-09-18 Thread Nikola Janceski
]] Sent: Wednesday, September 18, 2002 9:06 AM To: [EMAIL PROTECTED] Subject: Array of Hashes Hi I want to put a hash into each element of an array. I do it like the following bit of code. When I iterate round my hash before putting it in the array of the hash values/keys

RE: Array of Hashes

2002-09-18 Thread Simon Tomlinson
: RE: Array of Hashes 18/09/2002 14:11

RE: Array of Hashes

2002-09-18 Thread NYIMI Jose (BMB)
[mailto:[EMAIL PROTECTED]] Sent: Wednesday, September 18, 2002 3:18 PM To: Nikola Janceski nikola_janceski; [EMAIL PROTECTED] Subject: RE: Array of Hashes Apologies, that was bad typing in my email. I rearrange the algorithm to make it easier to read. Here is my exact source and the exact

RE: Array of Hashes

2002-09-18 Thread Sudarshan Raghavan
On Wed, 18 Sep 2002, Simon Tomlinson wrote: Apologies, that was bad typing in my email. I rearrange the algorithm to make it easier to read. Here is my exact source and the exact output. Even without the space there, it still doesn't work!! Any ideas? Simon. sub getEvents {

RE: Array of Hashes

2002-09-18 Thread Simon Tomlinson
] [EMAIL PROTECTED]cc: .comSubject: RE: Array

Re: Array of Hashes

2002-09-18 Thread david
Simon Tomlinson wrote: Hi I want to put a hash into each element of an array. I do it like the following bit of code. When I iterate round my hash before putting it in the array of the hash values/keys are there. However, when I iterate through the hash after putting it in the array

Re: Array of Hashes

2002-09-18 Thread Dharmender Rai
assign the reference of the hash. --- Simon Tomlinson [EMAIL PROTECTED] wrote: Hi I want to put a hash into each element of an array. I do it like the following bit of code. When I iterate round my hash before putting it in the array of the hash values/keys are there. However, when I

Sorting an array of hashes

2002-02-06 Thread Tomasi, Chuck
Does anyone have any clever ideas for sorting an array of hashes based on a key such as an ID number? Example: @AoH = ( { ID = 10101, UserID = 1041, Status = 2 }, { ID = 10541, UserID = 1211, Status = 1 }, { ID = 10111, UserID = 1211, Status = 2 }, { ID = 10721

RE: Sorting an array of hashes

2002-02-06 Thread Nikola Janceski
; } -Original Message- From: Tomasi, Chuck [mailto:[EMAIL PROTECTED]] Sent: Wednesday, February 06, 2002 2:18 PM To: '[EMAIL PROTECTED]' Subject: Sorting an array of hashes Does anyone have any clever ideas for sorting an array of hashes based on a key such as an ID number

Re: Sorting an array of hashes

2002-02-06 Thread Chas Owens
On Wed, 2002-02-06 at 14:17, Tomasi, Chuck wrote: Does anyone have any clever ideas for sorting an array of hashes based on a key such as an ID number? Example: @AoH = ( { ID = 10101, UserID = 1041, Status = 2 }, { ID = 10541, UserID = 1211, Status = 1 }, { ID

Re: Sorting an array of hashes

2002-02-06 Thread Shawn
- Original Message - From: Tomasi, Chuck [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, February 06, 2002 1:17 PM Subject: Sorting an array of hashes Does anyone have any clever ideas for sorting an array of hashes based on a key such as an ID number? Example: @AoH

Re: Sorting an array of hashes

2002-02-06 Thread Brett W. McCoy
On Wed, 6 Feb 2002, Tomasi, Chuck wrote: Does anyone have any clever ideas for sorting an array of hashes based on a key such as an ID number? Example: @AoH = ( { ID = 10101, UserID = 1041, Status = 2 }, { ID = 10541, UserID = 1211, Status = 1 }, { ID = 10111

RE: Sorting an array of hashes

2002-02-06 Thread Tomasi, Chuck
:28 PM To: 'Tomasi, Chuck'; '[EMAIL PROTECTED]' Subject: RE: Sorting an array of hashes @sorted = sort { $a-{ID} = $b-{ID} ## remember that $a and $b become the element of the array ## so if it's a reference to a hash use a dereferencer '-' or # $$a{ID} = $$b{ID

array of hashes

2001-10-31 Thread Sofia
I have a systems hash that contains the type of system as keys and the name of the machines as values: %systems = ( sgi = [sgi1, sgi2], linux = [linux1, linux2], dec = [dec1, dec2] }; Now, each type of system has default values like an email help address, shell used, users home

  1   2   >