> 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
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
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
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
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
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
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
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 sort in ascending order the first index of the
>>> array
>>> then
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 wou
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 sort to:
>
> 97,2,120,65
>
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", @{
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 the array
>> then the second index of the
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 "first element" rather than "first
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
> > array then the second index of the array
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?
--
Just my 0
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
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:/
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
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
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
- 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 my hash key 'Monday' w
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.
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
"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
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
#use strict;
use warnings
"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 written as
$HOA{ $key } = [ 'a' .. 'd' ];
> how do i push an eleme
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 de-referencing it:
push @{ $HOA{
>
> 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
--
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
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
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
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:
> 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]
:[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 {}
[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" => [EMAIL PROTECTED]
}
};
But by doing so I am not getting the values for the respective keys.
-Original Message-
From: Tim Johnson [mailto:[EMAIL PROTECTED]
Sent: Wednesday, May 05, 2004 11:01 AM
To: Suresh Pasupula (WT01 - EMBEDDED & PRODUCT ENGINEERING SOLUTIONS);
[EMAIL PROTECTED]
Subject: RE: [ Hash
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
@{$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
First I'll show you ONE of the right ways:
use strict;
use warnings;
#declare the arrays
my @one = ("abc", "def");
my @two = ("ABC", "DEF");
#initialize the hash (note the parens)
my %ModelPath = ();
#add the arrays to the hash
$ModelPath{1} = [EMAIL PROTECTED];
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"}
Dereferencing the array was exactly what I wanted. Thank you!
"James Edward Gray II" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
>
> On Thursday, September 11, 2003, at 06:58 AM, Phillip E. Thomas wrote:
>
> > my %hash=();
> > my $mykey="key";
> > my $myval1=$myval2="test";
> >
>
> my %hash=();
> my $mykey="key";
> my $myval1=$myval2="test";
>
> #store data in a hash of arrays
> $hash{$mykey}=[$myval1, $myval2];
>
> Later on I want to retrieve the data and I have to do it like:
>
> $myval1=$hash{$mykey}[0];
> $myval2=$hash{$mykey}[1];
>
> There are a lot of array values
On Thursday, September 11, 2003, at 06:58 AM, Phillip E. Thomas wrote:
my %hash=();
my $mykey="key";
my $myval1=$myval2="test";
#store data in a hash of arrays
$hash{$mykey}=[$myval1, $myval2];
Later on I want to retrieve the data and I have to do it like:
$myval1=$hash{$mykey}[0];
$myval2=$hash
Nicole Seitz wrote:
>
> hi there!
Hello,
> I've got a problem with a complex data structure and hope you can help me.
>
> I know that I can't have a hash whose values are arrays. So I tried to
> build a hash of references to arrays.
>
> I guess I've made some mistakes .
>
> This is what my
Hi Nicole
"Nicole Seitz" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> hi there!
>
> I've got a problem with a complex data structure and hope you can help
me.
>
> I know that I can't have a hash whose values are arrays. So I tried to
> build a hash of refer
Nicole Seitz wrote:
> hi there!
>
> I've got a problem with a complex data structure and hope you can
> help me.
>
> I know that I can't have a hash whose values are arrays. So I tried
> to build a hash of references to arrays.
>
> I guess I've made some mistakes .
>
> This is what my hash
On Wednesday 25 July 2001 10:26, Diego Riaño wrote:
> I want to retrieve the name of one of the original arrays, for example
> retrieve:
>
> @NumericalResults
> to use it in another function.
Hmmm, I'm not sure what you're getting at here. You've create a hash or
arrays, why not just pass a ref
On Thu, 28 Jun 2001, F.H wrote:
> I just wonder why the if condition is always true regardless of the value of the
>array AB.
> @AB = [1,2], and $i gets printed even for values not inlcuded in array AB.
>
> foreach $i ( 0 .. $#{ $testsec{'AB'} } ) {
> if ($testsec{'AB'}[$i] = "6543")
You've got caught in the old = vs == trap. A single = sign sets the variable
on the left to equal that on the right, while == tests for equality. So in
your case
$testsec{'AB'}[$i] = "6543"
sets $testsec{'AB'}[$i] to "6543", and then returns 'true' (yes, I have
successfully set that var
--- Paul <[EMAIL PROTECTED]> wrote:
>
> --- "F.H" <[EMAIL PROTECTED]> wrote:
> > I just wonder why the if condition is always true regardless of the
> > value of the array AB.
> > if ($testsec{'AB'}[$i] = "6543"){ # always true
>
> Because = is an assignment. =o)
>
> print "fo
--- "F.H" <[EMAIL PROTECTED]> wrote:
> I just wonder why the if condition is always true regardless of the
> value of the array AB.
> if ($testsec{'AB'}[$i] = "6543"){ # always true
Because = is an assignment. =o)
print "foo" if $x = "65343";
will always print, because = retu
($title, $rest) = split ' ', $_, 2;
@fields = split ' ',$rest;
last two lines === ($title, @fields) = split ' ';
which is almost ($title, @fields) = split;
foreach $keytitle (keys %TITLES) {
if ( grep /$keytitle/, $lookup ) {
$lookup is an arr
--- "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
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';
$
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
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:
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
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
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
59 matches
Mail list logo