Re: help with Hash of arrays of arrays

2015-07-02 Thread Илья Рассадин
seful from your problem domain). Final code https://gist.github.com/elcamlost/54f32cd48ae1106052e0 чт, 2 июля 2015 г. в 13:03, Nathalie Conte : > HI Shlomi, > Thanks for your comments about best practise which I have implemented, Any > ideas on why my hash of arrays of arrays is misbehavin

Re: help with Hash of arrays of arrays

2015-07-02 Thread Nathalie Conte
HI Shlomi, Thanks for your comments about best practise which I have implemented, Any ideas on why my hash of arrays of arrays is misbehaving? Thanks Nat On 1 Jul 2015, at 15:42, Shlomi Fish wrote: > Hi Nat, > > some comments about your code. > > On Wed, 1 Jul 2015 13:00

Re: help with Hash of arrays of arrays

2015-07-01 Thread Shlomi Fish
data10 > gene bal3 data5 data6 data12 > gene bal4 data7 data8 data12 > > I take each data variable, see above, from a sql query and parse the data > to build a new data structure: a hash of arrays of arrays. > In the input data presented here, the fi

help with Hash of arrays of arrays

2015-07-01 Thread nconte
and parse the data to build a new data structure: a hash of arrays of arrays. In the input data presented here, the first column will be the key of the hash and the other 4 columns should compose 4 arrays. example :Each gene (gene a gene b ..) should be the keys, the al column should be the first

RE: reading a hash of arrays

2014-11-19 Thread Frank K.
Subject: Re: reading a hash of arrays On Wed, 19 Nov 2014 17:03:40 -0600 "Frank K." wrote: > I can't do @array1 = @hash{one}; @array1 = @{ $hash{one} }; $hash{one} contains a reference to an array. By dereferencing it with @{ ... }, you get the array. -- Don't

Re: reading a hash of arrays

2014-11-19 Thread Shawn H Corey
On Wed, 19 Nov 2014 17:03:40 -0600 "Frank K." wrote: > I can't do @array1 = @hash{one}; @array1 = @{ $hash{one} }; $hash{one} contains a reference to an array. By dereferencing it with @{ ... }, you get the array. -- Don't stop where the ink does. Shawn -- To unsubscribe, e-mail: b

reading a hash of arrays

2014-11-19 Thread Frank K.
Have a hash of arrays.. i.e. $hash{one}[0] = "value 10"; $hash{one}[1] = "value 11"; $hash{one}[2] = "value 11"; $hash{one}[3] = "value 13"; $hash{one}[0] = "value 20"; $hash{one}[1] = "value 21"; $hash{one}[2] = "value 22&

RE: Creating a hash of arrays from

2014-07-10 Thread Sunita Pradhan
}; I guess you want output something like this . > From: p...@surfshopcart.com > Subject: Creating a hash of arrays from > Date: Wed, 9 Jul 2014 18:59:58 -0700 > To: beginners@perl.org > > I'm having a problem creating a hash of arrays. The while loop below > works,

Re: Creating a hash of arrays from

2014-07-10 Thread SSC_perl
On Jul 10, 2014, at 9:00 AM, Ron Bergin wrote: > my($state, @zipcodes) = split /[=,]/, $line; Interesting concept, the multiple split. I'd be interested in knowing how Perl knows to give the singular value on the left of the "=" to $state and all other values split on the "," to @zipcod

Re: Creating a hash of arrays from

2014-07-10 Thread Ron Bergin
Ron Bergin wrote: > Others have already pointed what you were doing wrong, so I'll point out > something else. > > Instead of using 2 separate split statements, I'd use a single split > statement to assign $state and a @zipcodes array. > > use 5.010; > use strict; > use warnings; > use Data::Dumpe

Re: Creating a hash of arrays from

2014-07-10 Thread Ron Bergin
SSC_perl wrote: > If someone could explain what I'm doing wrong, I'd appreciate it. I > just > can't see it. > > Thanks, > Frank > > -- > > use strict; > use warnings; > use 5.010; > > use Data::Dumper; > > my %entries; > > while (my $line = ) { > chomp $line;

Re: Creating a hash of arrays from

2014-07-10 Thread Nathan Hilterbrand
Hi Frank On 07/10/2014 11:02 AM, SSC_perl wrote: On Jul 10, 2014, at 7:14 AM, Nathan Hilterbrand wrote: $entries{$state} = [ (split /,/ => $zipcodes) ]; Thanks, Nathan. The line above caught my eye. It's interesting to see that you don't need both 'push' and 'split' to populate th

Re: Creating a hash of arrays from

2014-07-10 Thread SSC_perl
On Jul 10, 2014, at 7:14 AM, Nathan Hilterbrand wrote: > $entries{$state} = [ (split /,/ => $zipcodes) ]; Thanks, Nathan. The line above caught my eye. It's interesting to see that you don't need both 'push' and 'split' to populate the hash. Could you explain a little about wh

Re: Creating a hash of arrays from

2014-07-09 Thread SSC_perl
On Jul 9, 2014, at 7:56 PM, John SJ Anderson wrote: > This foreach loop is looping over the five zip codes in the array... > >> print Dumper (@{$entries{$state}}); > > And printing out the same array each time. Thanks, John. I wasn't even looking at the printout loop. :\ For so

Re: Creating a hash of arrays from

2014-07-09 Thread John SJ Anderson
On Wed, Jul 9, 2014 at 6:59 PM, SSC_perl wrote: > If someone could explain what I'm doing wrong, I'd appreciate it. I > just can't see it. You're looping over the entries in the array, not the entries in the hash. > foreach my $state (sort keys %entries) { > say "The Zip Codes of $

Creating a hash of arrays from

2014-07-09 Thread SSC_perl
I'm having a problem creating a hash of arrays. The while loop below works, but it's working too well. ;) Instead of giving me 5 values (from the example data below), it's giving me 25. I don't understand why it seems to be "looping" through the push

Re: hash of arrays sorting

2012-08-23 Thread Salvador Fandino
> IIRC, a long time ago I send you a patch for Sort::Maker benchmarking > script incorporating Sort::Key variants that showed how faster my module > can be. I would try to find it and send it to you again. Well, I have been unable to find it... but I have redone it :-) Attached are the patch tha

Re: hash of arrays sorting

2012-08-23 Thread Salvador Fandino
On 08/23/2012 09:10 AM, Uri Guttman wrote: > On 08/23/2012 02:54 AM, Salvador Fandino wrote: > >>> >>> It's a pity Sort::Maker not in Debian >> >> There is also Sort::Key, available in Debian testing and unstable, and >> which is usually faster than Sort::Maker and also Sort::Key::Radix, even >> f

Re: hash of arrays sorting

2012-08-23 Thread Rob Coops
On Thu, Aug 23, 2012 at 9:10 AM, Uri Guttman wrote: > On 08/23/2012 02:54 AM, Salvador Fandino wrote: > > >>> It's a pity Sort::Maker not in Debian >>> >> >> There is also Sort::Key, available in Debian testing and unstable, and >> which is usually faster than Sort::Maker and also Sort::Key::Radi

Re: hash of arrays sorting

2012-08-23 Thread Uri Guttman
On 08/23/2012 02:54 AM, Salvador Fandino wrote: It's a pity Sort::Maker not in Debian There is also Sort::Key, available in Debian testing and unstable, and which is usually faster than Sort::Maker and also Sort::Key::Radix, even faster when sorting by numeric keys but not available in Debian

Re: hash of arrays sorting

2012-08-22 Thread Salvador Fandino
On 08/22/2012 10:34 PM, Eduardo wrote: > On 22/08/12 03:49, Uri Guttman wrote: >> On 08/21/2012 08:29 PM, Eduardo wrote: >>> how would you do with Sort::Maker? >> i don't have time to show an example now but it is much cleaner >> looking. all you need to do is code up how you extract each key from

Re: hash of arrays sorting

2012-08-22 Thread Eduardo
On 22/08/12 03:49, Uri Guttman wrote: > On 08/21/2012 08:29 PM, Eduardo wrote: >> how would you do with Sort::Maker? > i don't have time to show an example now but it is much cleaner > looking. all you need to do is code up how you extract each key from > the data set and how it gets sorted (number

Re: hash of arrays sorting

2012-08-21 Thread Uri Guttman
On 08/21/2012 08:29 PM, Eduardo wrote: On 22/08/12 00:35, Uri Guttman wrote: my %cache = (); foreach ( keys %$hash ) { my ( $naa, $nab ) = $_ =~ m|^(\d+)-(\d+)|; $cache{ ($naa * 100 + $nab ) } = $_; } that is a variant of the orcish manoever which is supported by sort::maker. fore

Re: hash of arrays sorting

2012-08-21 Thread Eduardo
On 22/08/12 00:35, Uri Guttman wrote: > On 08/21/2012 05:33 PM, Eduardo wrote: >> On 21/08/12 22:05, Chris Stinemetz wrote: >>> Hello List, >>> >>> I am trying to sort a hash of arrays ( example below: ) >>> >>> I would the sort to so

Re: hash of arrays sorting

2012-08-21 Thread Uri Guttman
On 08/21/2012 05:33 PM, Eduardo wrote: On 21/08/12 22:05, Chris Stinemetz wrote: Hello List, I am trying to sort a hash of arrays ( example below: ) I would the sort to sort in ascending order the first index of the array then the second index of the array. So in this example the arrays

Re: hash of arrays sorting

2012-08-21 Thread Eduardo
On 21/08/12 22:05, Chris Stinemetz wrote: > Hello List, > > I am trying to sort a hash of arrays ( example below: ) > > I would the sort to sort in ascending order the first index of the array > then the second index of the array. > > So in this example the arrays would

Re: hash of arrays sorting

2012-08-21 Thread Chris Stinemetz
I will leave it to you to write an actual program incorporating these > ideas. > > Thank you Jim for the excelent explanation. This seems to do the trick. foreach my $cellNo ( sort { $hash{$a}->[0] <=> $hash{$b}->[0] || $hash{$a}->[1] <=> $hash{$b}->[1] } keys %hash ) { print join( "\0", @{

Re: hash of arrays sorting

2012-08-21 Thread Jim Gibson
On Aug 21, 2012, at 1:23 PM, Jim Gibson wrote: > > On Aug 21, 2012, at 1:05 PM, Chris Stinemetz wrote: > >> Hello List, >> >> I am trying to sort a hash of arrays ( example below: ) >> >> I would the sort to sort in ascending order the first index of th

Re: hash of arrays sorting

2012-08-21 Thread Jim Gibson
On Aug 21, 2012, at 1:05 PM, Chris Stinemetz wrote: > Hello List, > > I am trying to sort a hash of arrays ( example below: ) > > I would the sort to sort in ascending order the first index of the array > then the second index of the array. I believe you mean "fir

Re: hash of arrays sorting

2012-08-21 Thread Chris Stinemetz
On Tue, Aug 21, 2012 at 3:11 PM, Shawn H Corey wrote: > On Tue, 21 Aug 2012 15:05:33 -0500 > Chris Stinemetz wrote: > > > I am trying to sort a hash of arrays ( example below: ) > > > > I would the sort to sort in ascending order the first index of the > > a

Re: hash of arrays sorting

2012-08-21 Thread Shawn H Corey
On Tue, 21 Aug 2012 15:05:33 -0500 Chris Stinemetz wrote: > I am trying to sort a hash of arrays ( example below: ) > > I would the sort to sort in ascending order the first index of the > array then the second index of the array. What have you tried so far? Can we see the code?

hash of arrays sorting

2012-08-21 Thread Chris Stinemetz
Hello List, I am trying to sort a hash of arrays ( example below: ) I would the sort to sort in ascending order the first index of the array then the second index of the array. So in this example the arrays would sort to: 97,2,120,65 219,1,30,33 280,3,230,90 462,2,270,65 $VAR1

Re: Foreach loop and hash of arrays

2012-02-07 Thread Shawn H Corey
On 12-02-07 06:26 AM, Rob Dixon wrote: in fact, if the objective is to reduce the code to something as brief as possible then this will do the trick my $match = (grep $_ eq $customers_zip, @{$states{$customers_state}}) ? 'yes' : 'no'; You can use first from List::Util for more efficient cod

Re: Foreach loop and hash of arrays

2012-02-07 Thread Rob Dixon
On 07/02/2012 01:39, sono...@fannullone.us wrote: On Feb 6, 2012, at 1:42 PM, Steve Bertrand wrote: This may be easier. It uses the hash elements directly as an array, then uses grep to see if the zip code is within the specific state. It returns true if the state owns that zip code, and false

Re: Foreach loop and hash of arrays

2012-02-06 Thread sono-io
On Feb 6, 2012, at 1:42 PM, Steve Bertrand wrote: > This may be easier. It uses the hash elements directly as an array, then uses > grep to see if the zip code is within the specific state. It returns true if > the state owns that zip code, and false if it doesn't. > > if ( grep( /^$customers_z

Re: Foreach loop and hash of arrays

2012-02-06 Thread Robert Wohlfarth
On Mon, Feb 6, 2012 at 3:14 PM, wrote: >So I'm creating a hash of arrays that contains a list of Zip Codes > for the United States. I've also written a foreach loop to access this > hash but I'd like to see if it could be written better. For example, do I >

Re: Foreach loop and hash of arrays

2012-02-06 Thread Uri Guttman
On 02/06/2012 04:58 PM, Parag Kalra wrote: On Mon, Feb 6, 2012 at 1:14 PM, wrote: For example, do I really need three foreach loops? You can get rid of third ForLoop for sure. you don't actually lose the third loop. grep is an implied loop. STATE: foreach my $state (keys %states

Re: Foreach loop and hash of arrays

2012-02-06 Thread Rob Dixon
On 06/02/2012 21:14, sono...@fannullone.us wrote: use strict; use warnings; my %states = ( AL => [ '350','351', ], AK => [ '995','996', ], AZ => [ '850','851', ], AR => [ '716','717', ], ); my $customers_state = 'AZ'; my $customers_zip = '850'; my $match = 'n

Re: Foreach loop and hash of arrays

2012-02-06 Thread Parag Kalra
On Mon, Feb 6, 2012 at 1:14 PM, wrote: >For example, do I really need three foreach loops? > > > You can get rid of third ForLoop for sure. use strict; use warnings; my %states = ( AL => [ '350','351', ], AK => [ '995','996', ], AZ => [ '850','851', ], AR => [ '

Re: Foreach loop and hash of arrays

2012-02-06 Thread Steve Bertrand
On 2012.02.06 16:14, sono...@fannullone.us wrote: I have a web form where people enter their address info and I want to make sure that the first three digits of their Zip Code correspond to their State. So I'm creating a hash of arrays that contains a list of Zip Code

Foreach loop and hash of arrays

2012-02-06 Thread sono-io
I have a web form where people enter their address info and I want to make sure that the first three digits of their Zip Code correspond to their State. So I'm creating a hash of arrays that contains a list of Zip Codes for the United States. I've also written a fo

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

2010-01-18 Thread Chris Charley
- Original Message - From: ""Johnson, Reginald (GTS)"" Newsgroups: perl.beginners To: Sent: Sunday, January 17, 2010 2:42 PM Subject: hash of Arrays I am trying to place the date of each day of the week for each month that has 5 weeks into a hash. For instance

Re: hash of Arrays

2010-01-18 Thread Dermot
2010/1/17 Johnson, Reginald (GTS) : > I am trying to place the date of each day of the week for each month > that has 5 weeks into a hash. For instance my hash key 'Monday' would > point to an array that has all the dates where Monday is in the fifth > week of the month. > I've got that part going.

Re: hash of Arrays

2010-01-18 Thread Shlomi Fish
Hi Reginald! On Sunday 17 Jan 2010 21:42:21 Johnson, Reginald (GTS) wrote: > I am trying to place the date of each day of the week for each month > that has 5 weeks into a hash. For instance my hash key 'Monday' would > point to an array that has all the dates where Monday is in the fifth > week o

hash of Arrays

2010-01-18 Thread Johnson, Reginald (GTS)
I am trying to place the date of each day of the week for each month that has 5 weeks into a hash. For instance my hash key 'Monday' would point to an array that has all the dates where Monday is in the fifth week of the month. I've got that part going. My problem is I am having a problem accessing

Re: Accessing hash of arrays?

2008-10-03 Thread Matej Cepl
On 2008-10-03, 16:57 GMT, Paul Lalli wrote: > %targetedMessages is a hash > $targetedMessages{$tFolder} is an element of that hash, that happens > to be a reference to an array. Of course, silly me, thanks! Matěj -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EM

Re: Accessing hash of arrays?

2008-10-03 Thread Paul Lalli
On Oct 3, 10:03 am, [EMAIL PROTECTED] (Matej Cepl) wrote: > I have a script for archiving email messages on IMAP (whole code > is available athttp://mcepl.fedorapeople.org/tmp/archiveIMAP.pl). I go through > all messages in one source folder and put all of those which > I want to archive to hash in

Re: Accessing hash of arrays?

2008-10-03 Thread Mr. Shawn H. Corey
On Fri, 2008-10-03 at 16:03 +0200, Matej Cepl wrote: > I have a script for archiving email messages on IMAP (whole code > is available at > http://mcepl.fedorapeople.org/tmp/archiveIMAP.pl). I go through > all messages in one source folder and put all of those which > I want to archive to hash

Accessing hash of arrays?

2008-10-03 Thread Matej Cepl
I have a script for archiving email messages on IMAP (whole code is available at http://mcepl.fedorapeople.org/tmp/archiveIMAP.pl). I go through all messages in one source folder and put all of those which I want to archive to hash indexed by the target folder: ... $targetFolder = getTargetFol

Re: hash of arrays

2008-08-19 Thread Dr.Ruud
"Dr.Ruud" schreef: > "ANJAN PURKAYASTHA": >> $HOA{$key}= [qw(a,b,c,d)]; > > which is equivalent to > > $HOA{ $key } = [ 'a', 'b', 'c', 'd' ]; Oops, as Ron wrote, your qw(a,b,c,d) was probably meant to be qw(a b c d). -- Affijn, Ruud "Gewoon is een tijger." -- To unsubscribe, e-mail: [EMAI

Re: hash of arrays

2008-08-19 Thread Ron Bergin
On Aug 18, 1:03 pm, [EMAIL PROTECTED] (Anjan Purkayastha) wrote: > hi, > i'm struggling with a hash of arrays problem. > suppose i create the following HOA: > $HOA{$key}= [qw(a,b,c,d)]; I doubt that the results of that assignment is what you want/expect. #!/usr/bin/perl

Re: hash of arrays

2008-08-18 Thread Dr.Ruud
"ANJAN PURKAYASTHA" schreef: > i'm struggling with a hash of arrays problem. > suppose i create the following HOA: > $HOA{$key}= [qw(a,b,c,d)]; which is equivalent to $HOA{ $key } = [ 'a', 'b', 'c', 'd' ]; and can also be w

Re: hash of arrays

2008-08-18 Thread Mr. Shawn H. Corey
On Mon, 2008-08-18 at 16:03 -0400, ANJAN PURKAYASTHA wrote: > hi, > i'm struggling with a hash of arrays problem. > suppose i create the following HOA: > $HOA{$key}= [qw(a,b,c,d)]; > > how do i push an element into the $HOA{$key} array? > > tia, > anjan > By

hash of arrays

2008-08-18 Thread ANJAN PURKAYASTHA
hi, i'm struggling with a hash of arrays problem. suppose i create the following HOA: $HOA{$key}= [qw(a,b,c,d)]; how do i push an element into the $HOA{$key} array? tia, anjan -- = anjan purkayastha bioinformatics analyst whitehead institute for biomedical res

Re: Perl Hash of arrays : comparison

2006-03-21 Thread John W. Krahn
Sonika Sachdeva wrote: > Hi, Hello, > I have Hash of array. I want to compare the array values within the hash. > How can it be done? > > if ($eline =~ /$pattern/ ) { > $eline =~ /(.*)\"(\w+)\s(.*)\?(.*)\"/ ; my $uniq=$1; my > $url=$4; You shouldn't use the numerical variables i

Re: Perl Hash of arrays : comparison

2006-03-21 Thread Mr. Shawn H. Corey
Sonika Sachdeva wrote: I have Hash of array. I want to compare the array values within the hash. How can it be done? if ($eline =~ /$pattern/ ) { $eline =~ /(.*)\"(\w+)\s(.*)\?(.*)\"/ ; my $uniq=$1; my $url=$4; chomp($uniq);chomp($url); my @var= (

RE: Perl Hash of arrays : comparison

2006-03-21 Thread Timothy Johnson
Sachdeva [mailto:[EMAIL PROTECTED] Sent: Tuesday, March 21, 2006 4:53 PM To: beginners@perl.org Subject: Perl Hash of arrays : comparison Hi, I have Hash of array. I want to compare the array values within the hash. How can it be done? if ($eline =~ /$pattern/ ) { $eline =~ /(.*)\&quo

Perl Hash of arrays : comparison

2006-03-21 Thread Sonika Sachdeva
Hi, I have Hash of array. I want to compare the array values within the hash. How can it be done? if ($eline =~ /$pattern/ ) { $eline =~ /(.*)\"(\w+)\s(.*)\?(.*)\"/ ; my $uniq=$1; my $url=$4; chomp($uniq);chomp($url); my @var= ( split("&",$url) );

RE: Hash of Arrays

2005-09-23 Thread Jim
> > The part that confuses me is: > > ($who, $rest) = split /:\s*/, $line, 2; > > I understand that it takes the input and splits it into two > parts along the regular expression, but I can't figure out > what the 2 means. > split the expression into a maximum of 2 perldoc -f split --

RE: Hash of Arrays

2005-09-20 Thread Timothy Johnson
Matija Papec wrote: > > Christopher Spears wrote: >> while ($line = <>) { >> ($who, $rest) = split /:\s*/, $line, 2; >> @fields = split ' ', $rest; >> $HoA{$who} = [ @fields ]; >> } >> >> The part that confuses me is: >> >> ($who, $rest) = split /:\s*/, $line, 2; >> >> I understand t

Re: Hash of Arrays

2005-09-20 Thread Matija Papec
Christopher Spears wrote: while ($line = <>) { ($who, $rest) = split /:\s*/, $line, 2; @fields = split ' ', $rest; $HoA{$who} = [ @fields ]; } The part that confuses me is: ($who, $rest) = split /:\s*/, $line, 2; I understand that it takes the input and splits it into two parts alo

Fwd: Hash of Arrays

2005-09-20 Thread Philippe Aerts
-- Forwarded message -- From: Philippe Aerts <[EMAIL PROTECTED]> Date: 20-sep-2005 20:04 Subject: Re: Hash of Arrays To: Christopher Spears <[EMAIL PROTECTED]> Hi Christopher, The syntax of the split command is split /PATTERN/,EXPR,LIMIT Limit specifies the maximu

Re: Hash of Arrays

2005-09-20 Thread Prasanna Kothari
Hi. From documentation: perldoc -f split split /PATTERN/,EXPR,LIMIT If LIMIT is specified and positive, splits into no more than that many fields (though it may split into fewer). If LIMIT is unspecified or zero, trailing null fields are stripped. If LIMIT is negative, it is treated as if an ar

Re: Hash of Arrays

2005-09-20 Thread Ankur Gupta
On 9/20/2005 11:16 PM Christopher Spears wrote: I've been learning about data structures by reading the Programming Perl book. Here is a code snippet: while ($line = <>) { # If $line = "abcd: efgh: ijkl"; ($who, $rest) = split /:\s*/, $line, 2; # then $who = "abcd" and $rest = "efgh:

Hash of Arrays

2005-09-20 Thread Christopher Spears
I've been learning about data structures by reading the Programming Perl book. Here is a code snippet: while ($line = <>) { ($who, $rest) = split /:\s*/, $line, 2; @fields = split ' ', $rest; $HoA{$who} = [ @fields ]; } The part that confuses me is: ($who, $rest) = split /:\s*/, $li

Re: Net::SMTP and a hash of arrays

2005-09-02 Thread Gretar M Hreggvidsson
> > > > I need to send an email to several different recipients, all at > different mail servers. I thought that a hash of arrays (my first time) > would do the job nicely, but Net::SMTP complains that I can't "coerce > array into hash". > > Here's

Re: Net::SMTP and a hash of arrays

2005-09-02 Thread Gretar M Hreggvidsson
a hash of arrays (my first time) would do the job nicely, but Net::SMTP complains that I can't "coerce array into hash". Here's my script (Win32): # hash the recipients -> a hash of arrays!! woohoo! my %rcpts = ( 'mail.domain0.com' => [ '[EMAIL PROTE

Re: Net::SMTP and a hash of arrays

2005-09-02 Thread Ramprasad A Padmanabhan
$email->recipient(@{ rcpts{$server} }); Thats the error IMHO TRY @{$rcpts{$server}} Ram -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Net::SMTP and a hash of arrays

2005-09-01 Thread Ryan Frantz
Perlers, I need to send an email to several different recipients, all at different mail servers. I thought that a hash of arrays (my first time) would do the job nicely, but Net::SMTP complains that I can't "coerce array into hash". Here's my script (Win32): # hash

Re: Hash of Arrays, p. 276

2005-05-28 Thread Peter Rabbitson
> Please look at the definition and initialization of the hash. It is a hash > of array references, isn't it? Why does > $HoA{"flintstone"}[0] work, why is not it: $HoA{"flintstone"}->[0] > perldoc perlref Section: Using References Paragraph 3 $array[$x]->{"foo"}->[0]

Hash of Arrays, p. 276

2005-05-28 Thread Matthew Sacks
Greetings: I am continuing to read the Camel Book. I am reading about complex data structrures. On page 276, there is an example of a HoA. (I am typing from memory so this may not be exactly correct) $HoA{"flintstone"}[0] = "fred"; Please look at the definition and initialization of the hash.

hash of arrays

2005-01-16 Thread Ken Gillett
Why do I think of a possible solution within minutes of sending a question to this list:-( One difference between the scripts is that the one which fails ties the hash to a Berkeley DB file and this is the cause. Without that the first item is always successfully added, but once tied to the fil

RE: [ Hash of Arrays]

2004-05-05 Thread Tim Johnson
:[EMAIL PROTECTED] Sent: Wednesday, May 05, 2004 5:36 AM To: [EMAIL PROTECTED] Subject: Re: [ Hash of Arrays] If you want it to be a hash ref you need my $ModelPath = { ... }; and if you want it to be a hash you'd need to use () instead of {}

Re: [ Hash of Arrays]

2004-05-05 Thread JupiterHost.Net
[EMAIL PROTECTED] wrote: No, I want to use Hash of Arrays. I want to define the hash in a better manner say something similar to the following way. my %ModelPath = { "2800" => [EMAIL PROTECTED], "4345&qu

RE: [ Hash of Arrays]

2004-05-04 Thread suresh.pasupula
No, I want to use Hash of Arrays. I want to define the hash in a better manner say something similar to the following way. my %ModelPath = { "2800" => [EMAIL PROTECTED], "4345" => [EMAIL PROTECTED]

RE: [ Hash of Arrays]

2004-05-04 Thread Tim Johnson
Oops! That last line should be: my @tempArray = @{$_}; -Original Message- From: Tim Johnson Sent: Tuesday, May 04, 2004 10:36 PM To: [EMAIL PROTECTED]; [EMAIL PROTECTED] Subject: RE: [ Hash of Arrays] I think you might actually want an array of arrays (list of lists, etc

RE: [ Hash of Arrays]

2004-05-04 Thread Tim Johnson
@{$temp}; } -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Tuesday, May 04, 2004 10:22 PM To: [EMAIL PROTECTED] Subject: RE: [ Hash of Arrays] --- Also is there a better way to define a hash when I already have existing arrays rather than defining

RE: [ Hash of Arrays]

2004-05-04 Thread Tim Johnson
array and assign to a new array my @fullArray = @{$temp}; -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Tuesday, May 04, 2004 9:58 PM To: [EMAIL PROTECTED] Subject: [ Hash of Arrays] --- For eg. I have two arrays. my @one = ("ab

RE: [ Hash of Arrays]

2004-05-04 Thread suresh.pasupula
2004 10:37 AM To: Suresh Pasupula (WT01 - EMBEDDED & PRODUCT ENGINEERING SOLUTIONS) Subject: RE: [ Hash of Arrays] Hey Suresh, Try something like this: my @one = ("abc", "def"); my @two = ("ABC", "DEF"); my %ModelPath = {}; $ModelPath{"1"}

[ Hash of Arrays]

2004-05-04 Thread suresh.pasupula
Hi, I would like to initialize a hash of arrays and retrieve the contents of hash. For eg. I have two arrays. my @one = ("abc", "def"); my @two = ("ABC", "DEF"); Now I will initialize a hash in the following way. my %ModelPath = {}; $ModelPath{

RE: An Old Question on Sorting Hash of Arrays by Array element an d th en by key

2004-02-20 Thread Smith Jeff D
ect: Re: An Old Question on Sorting Hash of Arrays by Array element an d th en by key On Feb 19, 2004, at 3:20 PM, Smith Jeff D wrote: > Thanks, I must have missed it--I'll be getting back to it tomorrow > morning > to see what I missed in the original response. I thought I had run as

Re: An Old Question on Sorting Hash of Arrays by Array element an d th en by key

2004-02-20 Thread R. Joseph Newton
Smith Jeff D wrote: > Thanks for the feedback--maybe I screwed up but what happens for me is that > the ordered array (1) only lists the keys, not the array values the hash key > points to and (2) I still don't get an ordered list of the keys that are put > in the "ordered" array--it comes out un-

Re: An Old Question on Sorting Hash of Arrays by Array element an d th en by key

2004-02-19 Thread John W. Krahn
Rob Dixon wrote: > > James Edward Gray II wrote: > > > > The Moral: Don't use the original message. Use this one. > > Far more reliable is: "Don't do what I say, do what I mean." :) After all, Perl is a DWIM language. :-) John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [E

Re: An Old Question on Sorting Hash of Arrays by Array element an d th en by key

2004-02-19 Thread Rob Dixon
James Edward Gray II wrote: > > The Moral: Don't use the original message. Use this one. Far more reliable is: "Don't do what I say, do what I mean." :) Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

RE: An Old Question on Sorting Hash of Arrays by Array element an d th en by key

2004-02-19 Thread Smith Jeff D
Re: An Old Question on Sorting Hash of Arrays by Array element an d th en by key On Feb 19, 2004, at 10:48 AM, Smith Jeff D wrote: > I really need to order both the keys and one of the elements in the > array > stored as a value in the hash, preferably sort first on the first > eleme

Re: An Old Question on Sorting Hash of Arrays by Array element an d th en by key

2004-02-19 Thread James Edward Gray II
On Feb 19, 2004, at 3:20 PM, Smith Jeff D wrote: Thanks, I must have missed it--I'll be getting back to it tomorrow morning to see what I missed in the original response. I thought I had run as printed below. No worries. You probably did run my original response, which was flawed. Mark gave a

Re: An Old Question on Sorting Hash of Arrays by Array element an d th en by key

2004-02-19 Thread James Edward Gray II
On Feb 19, 2004, at 10:48 AM, Smith Jeff D wrote: I really need to order both the keys and one of the elements in the array stored as a value in the hash, preferably sort first on the first element of the array (my real application has four elements but the snippet I'm testing with has a two-el

Re: An Old Question on Sorting Hash of Arrays by Array element an d th en by key

2004-02-19 Thread Rob Dixon
Jeff Smith wrote: > > I really need to order both the keys and one of the elements in the array > stored as a value in the hash, preferably sort first on the first element of > the array (my real application has four elements but the snippet I'm testing > with has a two-element array) and then sort

Re: An Old Question on Sorting Hash of Arrays by Array element an d th en by key

2004-02-19 Thread WC -Sx- Jones
Smith Jeff D wrote: I really need to order both the keys and one of the elements in the array stored as a value in the hash, preferably sort first on the first element of the array (my real application has four elements but the snippet I'm testing with has a two-element array) and then sort secondl

RE: An Old Question on Sorting Hash of Arrays by Array element an d th en by key

2004-02-19 Thread Smith Jeff D
riginal Message- From: James Edward Gray II [mailto:[EMAIL PROTECTED] Sent: Thursday, February 19, 2004 11:37 AM To: Smith Jeff D Cc: '[EMAIL PROTECTED]' Subject: Re: An Old Question on Sorting Hash of Arrays by Array element an d th en by key On Feb 19, 2004, at 10:25 AM, Smith Jeff D

Re: An Old Question on Sorting Hash of Arrays by Array element an d th en by key

2004-02-19 Thread Rob Dixon
can it??--wouldn't it be better to do a while/each and get both key and > value for the HofA somehow?? > > -Original Message- > From: James Edward Gray II [mailto:[EMAIL PROTECTED] > Sent: Wednesday, February 18, 2004 6:49 PM > To: Smith Jeff D > Cc: [EMAIL PROTECT

Re: An Old Question on Sorting Hash of Arrays by Array element and then by key

2004-02-19 Thread WC -Sx- Jones
%HofA = (orange=>['ZZZ', 'ANDY'], red=>['AAA', 'AL'], blue=>['mmm','Betty'], yellow=>['aaa', 'ZEUS'], green=>['DDD','Mary Joe'], violet=>['MMM','Hugo'] ); my @ordered_keys = sort { $HofA{$a}[0] cmp $HofA{$b}[1] ||

Re: An Old Question on Sorting Hash of Arrays by Array element an d th en by key

2004-02-19 Thread James Edward Gray II
On Feb 19, 2004, at 10:25 AM, Smith Jeff D wrote: Thanks for the feedback--maybe I screwed up but what happens for me is that the ordered array (1) only lists the keys, not the array values the hash key points to and (2) I still don't get an ordered list of the keys that are put in the "ordered

Re: An Old Question on Sorting Hash of Arrays by Array element an d th en by key

2004-02-19 Thread WC -Sx- Jones
Smith Jeff D wrote: Thanks for the feedback--maybe I screwed up but what happens for me is that the ordered array (1) only lists the keys, not the array values the hash key points to and (2) I still don't get an ordered list of the keys that are put in the "ordered" array--it comes out un-ordered.

  1   2   >