Travis Thornhill wrote:
>
> Is there such a thing?
>
> I'm trying to take a HoH and make a reference to a sub-part of the hash.
>
> This doesn't work:
>
> my %sub_hash = $main_hash{'sub_hash'};
>
> I get the following error:
> Reference found where even-sized list expected at ./my_buggy_pro
Travis Thornhill wrote:
Is there such a thing?
Yes there is.
I'm trying to take a HoH and make a reference to a sub-part of the hash.
This doesn't work:
my %sub_hash = $main_hash{'sub_hash'};
I get the following error:
Reference found where even-sized list expected at ./my_buggy_program li
On Mon, Nov 10, 2008 at 3:52 PM, Travis Thornhill <[EMAIL PROTECTED]
> wrote:
> Is there such a thing?
>
> I'm trying to take a HoH and make a reference to a sub-part of the hash.
>
> This doesn't work:
>
> my %sub_hash = $main_hash{'sub_hash'};
>
> I get the following error:
> Reference found whe
On Mon, Nov 10, 2008 at 09:52, Travis Thornhill
<[EMAIL PROTECTED]> wrote:
> Is there such a thing?
>
> I'm trying to take a HoH and make a reference to a sub-part of the hash.
>
> This doesn't work:
>
> my %sub_hash = $main_hash{'sub_hash'};
>
> I get the following error:
> Reference found where e
From: "Beginner" <[EMAIL PROTECTED]>
> On 9 Nov 2007 at 20:04, Jenda Krynicky wrote:
> > @[EMAIL PROTECTED] = map [$valone[$_], $valtwo[$_]] (0..$#valone);
> >
> >
> > The map produces a list of arrayrefs, each referenced array contains
> > one item from @valone and one from @va
On 9 Nov 2007 at 20:04, Jenda Krynicky wrote:
> From: "Beginner" <[EMAIL PROTECTED]>
> > On 9 Nov 2007 at 16:35, Jenda Krynicky wrote:
> >
> > > From: "Beginner" <[EMAIL PROTECTED]>
> > > > #!/bin/perl
> > > >
> > > > use strict;
> > > > use warnings;
> > > > use Data::Dumper;
> > > >
> > > > m
From: "Beginner" <[EMAIL PROTECTED]>
> On 9 Nov 2007 at 16:35, Jenda Krynicky wrote:
>
> > From: "Beginner" <[EMAIL PROTECTED]>
> > > #!/bin/perl
> > >
> > > use strict;
> > > use warnings;
> > > use Data::Dumper;
> > >
> > > my @keys = qw(fe fi fo thumb);
> > > my @valone = 1..4;
> > > my @valt
On Nov 9, 11:09 am, [EMAIL PROTECTED] (Beginner) wrote:
> What I was attempting was to have each key to be assigned the
> coresponding items from the array.
Why didn't you just say that in the first place, rather than letting
everyone guess as to what you wanted?
> So it might look like something
Beginner wrote:
On 9 Nov 2007 at 14:59, Rob Dixon wrote:
Beginner wrote:
Is it possible to make a hash slice like so
It's certainly possible, but I'm not sure why you've taken a reference
to your key and value arrays. [EMAIL PROTECTED] is a single scalar value, as is
[EMAIL PROTECTED], so
On Nov 9, 4:09 pm, [EMAIL PROTECTED] (Beginner) wrote:
> On 9 Nov 2007 at 16:35, Jenda Krynicky wrote:
>
> What I was attempting was to have each key to be assigned the
> coresponding items from the array. So it might look like something
> like:
Right, so your question has nothing to do with hash
On Nov 9, 3:35 pm, [EMAIL PROTECTED] (Jenda Krynicky) wrote:
>
> @[EMAIL PROTECTED] = ( [EMAIL PROTECTED],[EMAIL PROTECTED]);
Note that _can_ also be written
@[EMAIL PROTECTED] = \( @valone, @valtwo);
But IMNSHO it this syntax should _only_ be used in code that is
intended as part of a respon
On 9 Nov 2007 at 16:35, Jenda Krynicky wrote:
> From: "Beginner" <[EMAIL PROTECTED]>
> > #!/bin/perl
> >
> > use strict;
> > use warnings;
> > use Data::Dumper;
> >
> > my @keys = qw(fe fi fo thumb);
> > my @valone = 1..4;
> > my @valtwo = 10..14;
> > my %hash;
> > @[EMAIL PROTECTED] = [EMAIL PR
On 9 Nov 2007 at 14:59, Rob Dixon wrote:
> Beginner wrote:
> > Hi all,
> >
> > Is it possible to make a hash slice like so
> Hey Dermot
Hi Rob,
> It's certainly possible, but I'm not sure why you've taken a reference
> to your key and value arrays. [EMAIL PROTECTED] is a single scalar value,
From: "Beginner" <[EMAIL PROTECTED]>
> #!/bin/perl
>
> use strict;
> use warnings;
> use Data::Dumper;
>
> my @keys = qw(fe fi fo thumb);
> my @valone = 1..4;
> my @valtwo = 10..14;
> my %hash;
> @[EMAIL PROTECTED] = [EMAIL PROTECTED],@valtwo];
[...] creates an array reference. You want
@[EM
Beginner wrote:
Hi all,
Is it possible to make a hash slice like so
my %hash;
@[EMAIL PROTECTED] = [EMAIL PROTECTED];
My efforts suggest not:
#!/bin/perl
use strict;
use warnings;
use Data::Dumper;
my @keys = qw(fe fi fo thumb);
my @vals = 1..4;
my %hash;
@[EMAIL PROTECTED] = [EMAIL PROTECT
renard wrote:
BE AWARE THAT THE BENCHMARK PROVIDES INCORRECT RESULTS.
Thnaks, I was aware of that, but still wanted a general idea :)
The tested code is within an anonymous subroutine while this does
executes, the results differ dramitcally from the results when the
tested code is enclosed withi
The slice version took about 10 seconds, the grep one took more than 1
minute.
Marcello
Thanks Marcello!
Your example, John's. and renards have been very helpful to help see the
point someone else was trying to make about watching what you include in
your benchmark.
I appreciate your time :)
JupiterHost.Net ha scritto:
In benchmarking some code I've come across something I did not expect:
slice:
use strict;
use warnings;
my @k=qw(1 2 3 4 5 6);
my %n;@[EMAIL PROTECTED] = @k;
print "hi" if exists $n{1};
print "hi" if exists $n{3};
print "hi" if exists $n{5};
print "hi" if exists $n{7};
p
> Lawrence Statton wrote:
[snip]
Gotcha, thx
So then can you suggest a method of benchmarking these 2 methods that
would be more accurate?
I believe John's solution was excellent at illustrating th deficiencies
in the way I was doing it and supplying a solution and answering my
question all at
#!/usr/bin/perl
use warnings;
use strict;
use Benchmark 'cmpthese';
my @k = qw( 1 2 3 4 5 6 );
cmpthese( -10, {
exists => sub {
my $count = 0;
my %hash;
@hash{ @k } = ();
for my $num ( 1, 3, 5, 7, 9, 11 ) {
$count++ if exists $hash{ $num };
JupiterHost.Net wrote:
In benchmarking some code I've come across something I did not expect:
slice:
use strict;
use warnings;
my @k=qw(1 2 3 4 5 6);
my %n;@[EMAIL PROTECTED] = @k;
print "hi" if exists $n{1};
print "hi" if exists $n{3};
print "hi" if exists $n{5};
print "hi" if exists $n{7};
print
> Thanks for your input :)
No problem -- I really do enjoy this. However, I do have some actual
WORK that I need to do today :(
> > Finally, there were serious errors in your methodology in your
>
> Serious? I thought "in the Big Picture, it won't matter a gnats eyebrow." :)
And I stand by t
Thanks for your input :)
Finally, there were serious errors in your methodology in your
Serious? I thought "in the Big Picture, it won't matter a gnats eyebrow." :)
original benchmark. It turns out the printing dominated the total
That is why I made both identical except for the difference I'm
co
Bakken, Luke wrote:
You have to stop spending so much time playing with all this bogus
benchmarking :)
It not bogus :) Its an example to find the best method for a project.
If you prefer I'll ask the question I was trying to answer with the
benchmark:
Assuming you have an array of 0-15 elements
print "hi" if $n{11};
What if it's value is 0, '', or undef? It would exist but your
test
would miss it :)
In that case "defined" would be a beter function to use.
ok, but I'm still not interested in the value of the key I;'m interested
inthe key, so why not exists since its made for hashes :)
> > You have to stop spending so much time playing with all this bogus
> > benchmarking :)
>
> It not bogus :) Its an example to find the best method for a project.
>
And I'll reiterate more clearly. Benchmarking is *not* the tool to find
the best method.
The BEST method for a project is that
- Original Message -
From: "JupiterHost.Net" <[EMAIL PROTECTED]>
Date: Tuesday, January 25, 2005 11:37 am
Subject: Re: hash slice/exists vs. grep benchmark weirdness...
>
> >
> > Just as an FYI, you don't need "exists" in your code at all.
> > You have to stop spending so much time playing with all this bogus
> > benchmarking :)
>
> It not bogus :) Its an example to find the best method for a project.
>
> If you prefer I'll ask the question I was trying to answer with the
> benchmark:
>
> Assuming you have an array of 0-15 elemen
[EMAIL PROTECTED] suggested:
> Just as an FYI, you don't need "exists" in your code at all.
> It is just a waste of time in your example. Should be beter writen as:
>
> print "hi" if $n{11};
Bad idea, if you consider this:
$n{'oops'} = 0;
print "hi" if $n{'oops'};
print "ho" if exists $n{'oop
Just as an FYI, you don't need "exists" in your code at all. It is just a
waste of time in your example. Should be beter writen as:
print "hi" if $n{11};
What if it's value is 0, '', or undef? It would exist but your test
would miss it :)
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additio
- Original Message -
From: "JupiterHost.Net" <[EMAIL PROTECTED]>
Date: Tuesday, January 25, 2005 11:01 am
Subject: Re: hash slice/exists vs. grep benchmark weirdness...
> > You have to stop spending so much time playing with all this bogus
> > benchmarking :)
You have to stop spending so much time playing with all this bogus
benchmarking :)
It not bogus :) Its an example to find the best method for a project.
If you prefer I'll ask the question I was trying to answer with the
benchmark:
Assuming you have an array of 0-15 elements is it quicker/more ef
> In benchmarking some code I've come across something I did not expect:
>
You have to stop spending so much time playing with all this bogus
benchmarking :)
> slice:
> use strict;
> use warnings;
> my @k=qw(1 2 3 4 5 6);
> my %n;@[EMAIL PROTECTED] = @k;
> print "hi" if exists $n{1};
> print "h
33 matches
Mail list logo