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

Re: Array of Hashes - problem solved

2012-04-12 Thread Paul.G
Hi All I have solved the problem, I would be interested in any comments however on this script. Positive and negative comments are welcome. #!/usr/bin/perl use strict; use warnings; my @vggroup; my @PV; my $PV=0; my $Extents; my $AllocatedPE; my $rec = {}; my $href; my $extent;

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

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

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,

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]

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.

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

RE: Array of Hashes

2002-09-18 Thread Nikola Janceski
you have a space that shouldn't be there: print THIS DOESN'T WORK: $key $newHash {$key}\n; ^ should be: print THIS DOESN'T WORK: $key $newHash{$key}\n; -Original Message- From: Simon Tomlinson [mailto:[EMAIL

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

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 = ( Ssgi = [sgi1, sgi2], Slinux = [linux1, linux2], Sdec = [dec1, dec2] S }; S Now, each type of system has default values like an S email help address, shell

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

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 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/bash,/usr/home], dec =

Re: Array of Hashes?

2001-09-24 Thread Richard J. Barbalace
Jonathan Batchelor writes: I have a data structure similar to the following: @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

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/~japhy/ RPI