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 To: Perl Beginners Sent: Friday, 13 April 2012 6:08 AM Subject: Re: Array of Hashes Rob Dixon wrote: > > Hi Paul and welcome to the list. > > I c

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 o

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 hav

Re: Array of Hashes - problem solved

2012-04-12 Thread Paul.G
_ From: Paul.G To: "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 getti

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 wh

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:ðernetGlobalMode ($snmpS); 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

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:ðernet

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

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 th

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: [E

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

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-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 () { > if ($_ =~ m/stuff/) { > push(@data, {'vlan' => $vlan, 'host' => $host, 'mac' => $mac, 'port' > => $port}); > } > } > > Small sample of @da

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 () { if ($_ =~ m/stuff/) { push(@data, {'vlan' => $vlan, 'host' => $host, 'mac' => $mac, 'port' => $port}); } } Small sample of @data: vlan hostmac

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 () { if ($_ =~ m/stuff/) { push(@data, {'vlan' => $vlan, 'host' => $host, 'mac' => $mac, 'port' => $port}); } } Small sample of @data: vlan hostmacport 13 switch-1

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 f

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, 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 perl

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

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

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, ad

Re: reference to array of hashes in OOP

2007-07-11 Thread Inventor
On Jul 11, 5:09 pm, [EMAIL PROTECTED] (Mr. Shawn H. Corey) wrote: > 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

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

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 to

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]); # par

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 mult

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-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

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 yaron
From: [EMAIL PROTECTED] To: "pauld" <[EMAIL PROTECTED]> Cc: "beginners" 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

Re: accesing a hash of an array of hashes

2007-05-26 Thread yaron
frica/Harare שבת 26 מאי 2007 Subject: accesing 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 = $

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?

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 = $csv->

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 (prima

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

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

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 = [ > { > 'lo

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', 'locat

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

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 for the

Re: Looping over an array of hashes problem

2005-09-08 Thread John W. Krahn
Graeme McLaren wrote: > 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 ele

Re: Looping over an array of hashes problem

2005-09-08 Thread Jeff Pan
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 line 477, near &q

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

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

RE: array of hashes of arrays...

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

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] F

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]

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", >

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: 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 i

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 @{$pi

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 if

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. I'v

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 (ke

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

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

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

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 > pro

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 "an

RE: array of hashes looping prob

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

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} "; } } 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-

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

dereferencing array of hashes in a Tk widget

2004-09-13 Thread Michael Ragsdale
ter pulling the data from 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-&g

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

Re: Sorting an array of hashes

2004-08-05 Thread Gunnar Hjalmarsson
Chris Mortimore wrote: Gunnar Hjalmarsson wrote: 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...

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 o

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 Chris Devers
On Thu, 5 Aug 2004, Chris Mortimore wrote: Gunnar Hjalmarsson wrote: > 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, th

RE: Sorting an array of hashes

2004-08-05 Thread Chris Mortimore
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: http://www.g

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: http://www.gunnar.cc

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: 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 J

Re: Printing Array of Hashes

2003-12-23 Thread John W. Krahn
opulating an array 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 pe

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

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 va

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

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, w

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 arr

RE: Array of Hashes

2002-09-18 Thread Simon Tomlinson
bject: RE: Array of Hashes

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 getE

RE: Array of Hashes

2002-09-18 Thread NYIMI Jose (BMB)
cc:

RE: Array of Hashes

2002-09-18 Thread Simon Tomlinson
cc: Subject: RE: Array of Hashes

RE: Array of Hashes

2002-09-18 Thread Nikola Janceski
-- > From: Simon Tomlinson [mailto:[EMAIL PROTECTED]] > 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 ite

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 oupu

RE: Sorting an array of hashes

2002-02-06 Thread Tomasi, Chuck
06, 2002 1: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

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 =>

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 a

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 =>

RE: Sorting an array of hashes

2002-02-06 Thread Nikola Janceski
$item (@sorted){ print $item->{ID}, "\n"; } -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

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, Sta

Re: array of hashes

2001-10-31 Thread Michael Fowler
On Wed, Oct 31, 2001 at 09:53:58AM -0800, Sofia wrote: [snip] > %systems = ( >sgi => ["sgi1", "sgi2"], >linux => ["linux1", "linux2"], >dec => ["dec1", "dec2"] > }; [snip] > %default = ( > sgi => ["sgi-help","/bin/csh","/home"], > linux => > ["someaddress-help","/bin/bas

Re: array of hashes

2001-10-31 Thread Jeff 'japhy' Pinyan
On Oct 31, Sofia said: >So in the example that Daniel shows, how would I get >(reference) the value for the shell path for the sgi >system? Using the data structure: >> %systems = ( >> sgi => { defaults => >> ["sgi-help","/bin/csh","/home"], >> machines => ["sgi1", "sgi2

Re: array of hashes

2001-10-31 Thread Sofia
So in the example that Daniel shows, how would I get (reference) the value for the shell path for the sgi system? --- Daniel Gardner <[EMAIL PROTECTED]> wrote: > S> I have a systems hash that contains the type of > system > S> as keys and the name of the machines as values: > > S> %systems = (

Re: array of hashes

2001-10-31 Thread Sofia
Daniel, I am recreating the systems password, group and shadow (when applicable) files. So if the script is run on an sgi system, for example, the files location is /etc. If it is run on a linux machine is /usr/local/system. If there are new users, create new directories for them: for sgis on

Re: array of hashes

2001-10-31 Thread Daniel Gardner
S> I have a systems hash that contains the type of system S> as keys and the name of the machines as values: S> %systems = ( S>sgi => ["sgi1", "sgi2"], S>linux => ["linux1", "linux2"], S>dec => ["dec1", "dec2"] S> }; S> Now, each type of system has default values like an S> email

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,

Re: Array of Hashes?

2001-09-24 Thread Jeff 'japhy/Marillion' Pinyan
On Sep 24, Pete Sergeant said: >@hosts = sort { %{$a}->{'name'} <=> %{$b}->{'name'} } @hosts; That (%{$x}->{key}) works for an ugly reason. It's probably a bug. @hosts = sort { $a->{name} cmp $b->{name} } @hosts; -- Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~jap

Re: Array of Hashes?

2001-09-24 Thread Richard J. Barbalace
; > ); > > How can produce a sorted list of the hashes based on the hostname and then > access each hash to print the details. > > Or is there a better way of organising my data? There might be better way. It's not clear to me that you need the array of hashes a

Re: Array of Hashes?

2001-09-24 Thread Pete Sergeant
> @hosts = ( list of hashes like below ... ); > %hosts = ( name => "hostname", > ipaddr => "www.xxx.yyy.zzz", > location => "location" >); > > How can produce a sorted list of the hashes based on the hostname and then > access each hash to print the details. > @hosts = sort { %{$a}

  1   2   >