Re: hash of arrays question

2011-11-17 Thread Rob Dixon
On 17/11/2011 07:56, Stefan Wiederoder wrote: Hello Brandon, thanks a lot for your help - your code works like a charm, I´ve already put in my script which is now generating puppet node/classes definitions. Sometimes, but very rarely, the answer to a question should include working code. It i

Re: hash of arrays question

2011-11-17 Thread Stefan Wiederoder
Hello Brandon, thanks a lot for your help - your code works like a charm, I´ve already put in my script which is now generating puppet node/classes definitions. bye , Stefan -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http:/

Re: hash of arrays question

2011-11-16 Thread John SJ Anderson
On Tuesday, November 15, 2011 at 11:10 , Stefan Wiederoder wrote: > Hello list, > > I´m using a json config file to read a file with server group > definitions, including group of groups like > this example: > > [jdoe@belbo]# cat groups.json > { > "G_Group_PR" : [ "serverA", "serverB" ], > "G_G

Re: hash of arrays question

2011-11-15 Thread Jim Gibson
On 11/15/11 Tue Nov 15, 2011 8:10 AM, "Stefan Wiederoder" scribbled: > Hello list, > > I´m using a json config file to read a file with server group > definitions, including group of groups like > this example: > > [jdoe@belbo]# cat groups.json > { > "G_Group_PR" : [ "serverA", "serve

Re: hash of arrays question

2011-11-15 Thread Brandon McCaig
Hello Stefan, On Tue, Nov 15, 2011 at 08:10:12AM -0800, Stefan Wiederoder wrote: > Hello list, > > I´m using a json config file to read a file with server group > definitions, including group of groups like > this example: > > [jdoe@belbo]# cat groups.json > { > "G_Group_PR" : [ "serverA

hash of arrays question

2011-11-15 Thread Stefan Wiederoder
Hello list, I´m using a json config file to read a file with server group definitions, including group of groups like this example: [jdoe@belbo]# cat groups.json { "G_Group_PR" : [ "serverA", "serverB" ], "G_Group_QS" : [ "serverC", "serverD" ], "G_All" : [ "G_Group_PR", "

Re: Hash of Arrays Question

2001-05-01 Thread Paul
--- "J. Patrick Lanigan" <[EMAIL PROTECTED]> wrote: > I haven't quite sorted out the more complex data structure in perl > yet. Anyhow, I need to take the following hash of arrays... > > my %tracks = (); > > push @{$tracks{$filename}}, > $_, # tracks.fi

RE: Hash of Arrays Question

2001-05-01 Thread J. Patrick Lanigan
Thank you so much for your help Gary and Jason. I tried the following and it works perfectly. Patrick #!c:/perl/bin/perl -w use strict; my %tracks=(); # create empty hash $tracks{'test'}->{artist}='test_artist'; $tracks{'test'}->{title}='test_title'; $tracks{'test2'}->{artist}='test_artist2'; $

RE: Hash of Arrays Question

2001-05-01 Thread J. Patrick Lanigan
Opps, forgot to change the variable name. Ah the power of cut and paste... for my $row ( keys %tracks ) { $artist = $tracks{$row}->{artist}; $title = $tracks{$row}->{title}; } > I wrote: > > Excellent! Thanks! So, when I need to iterate through the hash of > hashes and > wor

RE: Hash of Arrays Question

2001-05-01 Thread J. Patrick Lanigan
Excellent! Thanks! So, when I need to iterate through the hash of hashes and work on the data would I do this: for my $row ( keys %tracks ) { $artist = $tracks{$fname}->{artist}; $title = $tracks{$fname}->{title}; } Thanks again for the pointer, Patrick > Gary Stainburn wrote:

Re: Hash of Arrays Question

2001-05-01 Thread Gary Stainburn
Surely, a hash of hashes would be better then. my %tracks=(); # create empty hash Then to populate the data you do something like: $tracks{$fname}->{artist}=$artist; $tracls{$fname}->{title}=$title; Gary On Tuesday 01 May 2001 4:08 pm, J. Patrick Lanigan wrote: > Overall what I am trying to

RE: Hash of Arrays Question

2001-05-01 Thread J. Patrick Lanigan
Overall what I am trying to accomplish is to loop through a bunch of mp3 files and extract the ID3 Tag Info into a hash (%tracks) for which each key references the filename, filepath, artist, album, tracknum, title, genre for one file. Once I have %tracks populated I need to iterate through it and

RE: Hash of Arrays Question

2001-05-01 Thread King, Jason
J. Patrick Lanigan writes .. >I haven't quite sorted out the more complex data structure in perl yet. >Anyhow, I need to take the following hash of arrays... you have some very confusing code there .. so let's do it one bit at a time >my %tracks = (); create a hash called tracks with zero e

Hash of Arrays Question

2001-05-01 Thread J. Patrick Lanigan
I haven't quite sorted out the more complex data structure in perl yet. Anyhow, I need to take the following hash of arrays... my %tracks = (); push @{$tracks{$filename}}, $_, # tracks.filename