[28387] in Perl-Users-Digest
Perl-Users Digest, Issue: 9751 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Sep 21 18:10:20 2006
Date: Thu, 21 Sep 2006 15:10:10 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Thu, 21 Sep 2006 Volume: 10 Number: 9751
Today's topics:
extracting inner key from a hash of hashes <doni.sekar@gmail.com>
Re: extracting inner key from a hash of hashes usenet@DavidFilmer.com
Re: extracting inner key from a hash of hashes <doni.sekar@gmail.com>
Re: extracting inner key from a hash of hashes <mritty@gmail.com>
Re: extracting inner key from a hash of hashes <David.Squire@no.spam.from.here.au>
Re: extracting inner key from a hash of hashes <glennj@ncf.ca>
Re: extracting inner key from a hash of hashes <tadmc@augustmail.com>
Re: extracting inner key from a hash of hashes <doni.sekar@gmail.com>
Re: extracting inner key from a hash of hashes <mritty@gmail.com>
Re: extracting inner key from a hash of hashes <mritty@gmail.com>
Re: extracting inner key from a hash of hashes <doni.sekar@gmail.com>
Re: extracting inner key from a hash of hashes <mritty@gmail.com>
Re: extracting inner key from a hash of hashes <doni.sekar@gmail.com>
Re: extracting inner key from a hash of hashes <glennj@ncf.ca>
Re: extracting inner key from a hash of hashes <David.Squire@no.spam.from.here.au>
Re: extracting inner key from a hash of hashes <doni.sekar@gmail.com>
Re: extracting inner key from a hash of hashes <doni.sekar@gmail.com>
Re: hashes question <ed@noreply.com>
Re: Help with plotting (reading news)
Re: How do I find the Nth index of array that is (whate <bik.mido@tiscalinet.it>
Re: How do I find the Nth index of array that is (whate <bik.mido@tiscalinet.it>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 21 Sep 2006 11:39:27 -0700
From: "doni" <doni.sekar@gmail.com>
Subject: extracting inner key from a hash of hashes
Message-Id: <1158863967.865420.165840@i42g2000cwa.googlegroups.com>
I have a doubt regarding extracting the inner key from a hash of
hashes.
Here is my hash structure.
%hash=(
mac-address1=>{
destn_address1, distance1
destn_address2, distance2
destn_address3, distance3
}
mac-address2=>{
destn_address1, distance1
destn_address2, distance2
destn_address3, distance3
}
mac-address3=>{
destn_address1, distance1
destn_address2, distance2
destn_address3, distance3
}
);
I was able to extract the distance portion like this.
$hash{$mac-address1}->{$destn address1}
I want to compare the destination address to see if it matches a
particular destination address. Is there anyway using a for-each loop
or any other means, can I extract the value of destination address.
Can anyone let me know, how can I do this or is there anyway can I do
it.
Thanks,
Sekar
------------------------------
Date: 21 Sep 2006 11:44:19 -0700
From: usenet@DavidFilmer.com
Subject: Re: extracting inner key from a hash of hashes
Message-Id: <1158864259.461696.303520@e3g2000cwe.googlegroups.com>
doni wrote:
> %hash=(
> mac-address1=>{
> destn_address1, distance1
> destn_address2, distance2
That ain't Perl.
Please either post actual code or actual Data::Dumper output for your
structure.
--
David Filmer (http://DavidFilmer.com)
------------------------------
Date: 21 Sep 2006 11:54:38 -0700
From: "doni" <doni.sekar@gmail.com>
Subject: Re: extracting inner key from a hash of hashes
Message-Id: <1158864877.879771.167230@h48g2000cwc.googlegroups.com>
David,
Here is the actual Data::Dumper output.
$VAR1 = '01:8e';
$VAR2 = {
'01:86' => 8,
'01:80' => 48,
'08:22' => 22
};
$VAR3 = '01:86';
$VAR4 = {
01:8e' => 8,
01:80' => 34,
'08:22' => 54
};
$VAR5 = '01:80';
$VAR6 = {
'01:8e' => 48,
'01:86' => 34,
'08:22' => 46
};
$VAR7 = '08:22';
$VAR8 = {
'01:8e' => 22,
'01:86' => 54,
'08:22' => 46
};
Thanks,
Sekar
usenet@DavidFilmer.com wrote:
> doni wrote:
>
> > %hash=(
> > mac-address1=>{
> > destn_address1, distance1
> > destn_address2, distance2
>
> That ain't Perl.
>
> Please either post actual code or actual Data::Dumper output for your
> structure.
>
> --
> David Filmer (http://DavidFilmer.com)
------------------------------
Date: 21 Sep 2006 11:56:30 -0700
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: extracting inner key from a hash of hashes
Message-Id: <1158864990.341077.237290@b28g2000cwb.googlegroups.com>
doni wrote:
> I have a doubt regarding extracting the inner key from a hash of
> hashes.
> Here is my hash structure.
>
> %hash=(
> mac-address1=>{
> destn_address1, distance1
> destn_address2, distance2
> destn_address3, distance3
> }
> mac-address2=>{
> destn_address1, distance1
> destn_address2, distance2
> destn_address3, distance3
> }
> mac-address3=>{
> destn_address1, distance1
> destn_address2, distance2
> destn_address3, distance3
> }
> );
>
>
> I was able to extract the distance portion like this.
> $hash{$mac-address1}->{$destn address1}
>
> I want to compare the destination address to see if it matches a
> particular destination address. Is there anyway using a for-each loop
> or any other means, can I extract the value of destination address.
> Can anyone let me know, how can I do this or is there anyway can I do
> it.
The answer to your question is "yes", but the real answer is "Are you
sure your structure is what it should be?
ddestn_addressX is the key to a hash. So you use the keys() function
on that hash:
for my $mac_address (keys %hash) {
for my $destn_address (keys %{$mac_address} ) {
if ($destn_address eq $particular_destin_address) {
# do something
}
}
}
Paul Lalli
------------------------------
Date: Thu, 21 Sep 2006 20:01:06 +0100
From: David Squire <David.Squire@no.spam.from.here.au>
Subject: Re: extracting inner key from a hash of hashes
Message-Id: <eeungi$huf$1@gemini.csx.cam.ac.uk>
doni wrote:
[Lesson 2: please don't top-post. Top-posting corrected. Perhaps you
might consider reading the posting guidelines for this group? They are
posted here twice a week.]
>
> usenet@DavidFilmer.com wrote:
>> doni wrote:
>>
>>> %hash=(
>>> mac-address1=>{
>>> destn_address1, distance1
>>> destn_address2, distance2
>> That ain't Perl.
>>
>> Please either post actual code or actual Data::Dumper output for your
>> structure.
> David,
>
> Here is the actual Data::Dumper output.
>
> $VAR1 = '01:8e';
> $VAR2 = {
> '01:86' => 8,
> '01:80' => 48,
> '08:22' => 22
> };
> $VAR3 = '01:86';
> $VAR4 = {
> 01:8e' => 8,
> 01:80' => 34,
> '08:22' => 54
> };
> $VAR5 = '01:80';
> $VAR6 = {
> '01:8e' => 48,
> '01:86' => 34,
> '08:22' => 46
> };
> $VAR7 = '08:22';
> $VAR8 = {
> '01:8e' => 22,
> '01:86' => 54,
> '08:22' => 46
> };
Ermm... how does this correspond to you original question, which seemed
to be about a single hash that in turn contained other hashes, etc. Here
you show eight separate variables, some of which are plain scalars, and
others which are hash references. I think we're going to need to see
some code.
DS
------------------------------
Date: 21 Sep 2006 19:05:09 GMT
From: Glenn Jackman <glennj@ncf.ca>
Subject: Re: extracting inner key from a hash of hashes
Message-Id: <slrneh5oj6.218.glennj@smeagol.ncf.ca>
At 2006-09-21 02:39PM, "doni" wrote:
> I have a doubt regarding extracting the inner key from a hash of
> hashes.
> Here is my hash structure.
>
> %hash=(
> mac-address1=>{
> destn_address1, distance1
> destn_address2, distance2
> destn_address3, distance3
> }
> mac-address2=>{
> destn_address1, distance1
> destn_address2, distance2
> destn_address3, distance3
> }
> mac-address3=>{
> destn_address1, distance1
> destn_address2, distance2
> destn_address3, distance3
> }
> );
you're missing a few commas up there.
> I was able to extract the distance portion like this.
> $hash{$mac-address1}->{$destn address1}
>
> I want to compare the destination address to see if it matches a
> particular destination address. Is there anyway using a for-each loop
> or any other means, can I extract the value of destination address.
> Can anyone let me know, how can I do this or is there anyway can I do
> it.
You want to know about dereferencing and the keys function.
my @mac_address1_destinations = keys %{ $hash{mac-address1} };
--
Glenn Jackman
Ulterior Designer
------------------------------
Date: Thu, 21 Sep 2006 14:03:32 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: extracting inner key from a hash of hashes
Message-Id: <slrneh5og4.ku0.tadmc@magna.augustmail.com>
doni <doni.sekar@gmail.com> wrote:
> Here is my hash structure.
>
> %hash=(
> mac-address1=>{
> destn_address1, distance1
> destn_address2, distance2
> destn_address3, distance3
> }
> I was able to extract the distance portion like this.
^^^^^^^^^^
> $hash{$mac-address1}->{$destn address1}
^ ^ ^
^ ^ ^
No you weren't! You have too many dollar signs and too few underscores.
Post Real Code (and data) if you want Real Help.
Have you seen the Posting Guidelines that are posted here frequently?
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 21 Sep 2006 12:11:11 -0700
From: "doni" <doni.sekar@gmail.com>
Subject: Re: extracting inner key from a hash of hashes
Message-Id: <1158865871.429331.161140@d34g2000cwd.googlegroups.com>
I couldn't conceive of a better way to have a structure as I am new to
this. If there is any better way, can you let me know.
Thanks,
Sekar
Paul Lalli wrote:
> doni wrote:
> > I have a doubt regarding extracting the inner key from a hash of
> > hashes.
> > Here is my hash structure.
> >
> > %hash=(
> > mac-address1=>{
> > destn_address1, distance1
> > destn_address2, distance2
> > destn_address3, distance3
> > }
> > mac-address2=>{
> > destn_address1, distance1
> > destn_address2, distance2
> > destn_address3, distance3
> > }
> > mac-address3=>{
> > destn_address1, distance1
> > destn_address2, distance2
> > destn_address3, distance3
> > }
> > );
> >
> >
> > I was able to extract the distance portion like this.
> > $hash{$mac-address1}->{$destn address1}
> >
> > I want to compare the destination address to see if it matches a
> > particular destination address. Is there anyway using a for-each loop
> > or any other means, can I extract the value of destination address.
> > Can anyone let me know, how can I do this or is there anyway can I do
> > it.
>
> The answer to your question is "yes", but the real answer is "Are you
> sure your structure is what it should be?
>
> ddestn_addressX is the key to a hash. So you use the keys() function
> on that hash:
>
> for my $mac_address (keys %hash) {
> for my $destn_address (keys %{$mac_address} ) {
> if ($destn_address eq $particular_destin_address) {
> # do something
> }
> }
> }
>
> Paul Lalli
------------------------------
Date: 21 Sep 2006 12:17:40 -0700
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: extracting inner key from a hash of hashes
Message-Id: <1158866260.227849.199630@d34g2000cwd.googlegroups.com>
doni wrote:
> Paul Lalli wrote:
> > doni wrote:
> > > I want to compare the destination address to see if it matches a
> > > particular destination address. Is there anyway using a for-each loop
> > > or any other means, can I extract the value of destination address.
> > > Can anyone let me know, how can I do this or is there anyway can I do
> > > it.
> >
> > The answer to your question is "yes", but the real answer is "Are you
> > sure your structure is what it should be?
> I couldn't conceive of a better way to have a structure as I am new to
> this. If there is any better way, can you let me know.
Please stop top posting. I am not the only person to ask this of you.
Trim the quoted material down to only the relevant bits, and then begin
your reply below it.
There is no way for anyone to tell you what the "right" structure to
use is, because you haven't actually said what your goal is. The only
question you asked related to how to get data out of the structure you
already have.
Paul Lalli
------------------------------
Date: 21 Sep 2006 12:18:41 -0700
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: extracting inner key from a hash of hashes
Message-Id: <1158866321.775306.310040@h48g2000cwc.googlegroups.com>
David Squire wrote:
> > $VAR1 = '01:8e';
> > $VAR2 = {
> > '01:86' => 8,
> > '01:80' => 48,
> > '08:22' => 22
> > };
> > $VAR3 = '01:86';
> > $VAR4 = {
> > 01:8e' => 8,
> > 01:80' => 34,
> > '08:22' => 54
> > };
> > $VAR5 = '01:80';
> > $VAR6 = {
> > '01:8e' => 48,
> > '01:86' => 34,
> > '08:22' => 46
> > };
> > $VAR7 = '08:22';
> > $VAR8 = {
> > '01:8e' => 22,
> > '01:86' => 54,
> > '08:22' => 46
> > };
>
> Ermm... how does this correspond to you original question, which seemed
> to be about a single hash that in turn contained other hashes, etc. Here
> you show eight separate variables, some of which are plain scalars, and
> others which are hash references.
Oh come on. David, you know full well that in this case, the OP simply
passed %hash to Dumper(), rather than \%hash. Let's not be too
snippity, shall we?
Paul Lalli
------------------------------
Date: 21 Sep 2006 12:23:12 -0700
From: "doni" <doni.sekar@gmail.com>
Subject: Re: extracting inner key from a hash of hashes
Message-Id: <1158866591.752928.11460@k70g2000cwa.googlegroups.com>
Paul,
My actual goal is to find the shortest path between the source and the
destination from the extracted information.
Thanks,
Sekar
Paul Lalli wrote:
> doni wrote:
> > Paul Lalli wrote:
> > > doni wrote:
>
> > > > I want to compare the destination address to see if it matches a
> > > > particular destination address. Is there anyway using a for-each loop
> > > > or any other means, can I extract the value of destination address.
> > > > Can anyone let me know, how can I do this or is there anyway can I do
> > > > it.
> > >
> > > The answer to your question is "yes", but the real answer is "Are you
> > > sure your structure is what it should be?
>
>
> > I couldn't conceive of a better way to have a structure as I am new to
> > this. If there is any better way, can you let me know.
>
> Please stop top posting. I am not the only person to ask this of you.
> Trim the quoted material down to only the relevant bits, and then begin
> your reply below it.
>
>
> There is no way for anyone to tell you what the "right" structure to
> use is, because you haven't actually said what your goal is. The only
> question you asked related to how to get data out of the structure you
> already have.
>
> Paul Lalli
------------------------------
Date: 21 Sep 2006 12:25:59 -0700
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: extracting inner key from a hash of hashes
Message-Id: <1158866759.265908.248960@d34g2000cwd.googlegroups.com>
doni wrote:
> Paul,
Bzzt. That's three. You're out. You were asked repeatedly to stop
top posting. You don't care about this simple request, I don't care
about helping you. Bye.
Paul Lalli
------------------------------
Date: 21 Sep 2006 12:27:55 -0700
From: "doni" <doni.sekar@gmail.com>
Subject: Re: extracting inner key from a hash of hashes
Message-Id: <1158866875.318663.169830@m73g2000cwd.googlegroups.com>
Here is my code snippet. It might be confusing...
while ($line=<TEST>)
{
my @value = split(/\s+/,$line);
### Removing unwanted output and also checking for valid path
###
if (($value[0] =~ m/^\d+/) && ($value[2] eq yes))
{
$upstr_mac[$i] = $value[1];
$dwnstr_mac[$i] = $value[0];
$rssi[$i] = $value[3];
$eval_rssi[$i] = (15 - $value[3])*4 + 8;
if ($i > 0)
{
if (($value[0] eq $upstr_mac[$i-1]) &&
($value[1] eq $mac))
{
$sum_rssi = ($value[3] + $rssi[$i-1])/2;
$eval_rssi[$j] = (15 - $sum_rssi)*4 + 8;
print "$sum_rssi\t$eval_rssi[$j]\n";
$calrssi{$mac}->{$dwnstr_mac[$i]} =
$eval_rssi[$j];
print "$dwnstr_mac[$i]\n";
print "rssi value with 1,$value[0] is:
$eval_rssi[$j]\n";
$j++;
}
elsif (($value[1] eq $dwnstr_mac[$i-1]) && ($value[0] eq $mac))
{
$sum_rssi = ($value[3] + $rssi[$i-1])/2;
$eval_rssi[$j] = (15 - $sum_rssi)*4 + 8;
print "$sum_rssi\t$eval_rssi[$j]\n";
$calrssi{$mac}->{$upstr_mac[$i]} =
$eval_rssi[$j];
print "$upstr_mac[$i]\n";
print "rssi value with 0,$value[1] is:
$eval_rssi[$j]\n";
$j++;
}
elsif (($value[0] eq $mac) && ($upstr_mac[$i-1] eq $mac) &&
($value[1] ne $dwnstr_mac[$i-1]) && ($value[1] ne $upstr_mac[$i+1]))
{
$sum_rssi = $value[3]/2;
$eval_rssi[$j] = (15 - $sum_rssi)*4 + 8;
$calrssi{$mac}->{$upstr_mac[$i]} =
$eval_rssi[$j];
$j++;
}
else
{
$sum_rssi = $value[3]/2;
$eval_rssi[$j] = (15 - $sum_rssi)*4 + 8;
$calrssi{$mac}->{$upstr_mac[$i]} =
$eval_rssi[$j];
$j++;
}
}
}
else
{
if ($value[2] =~ m/^\d+/)
{
$mac = $value[2];
print "MAC address for this part is $mac\n";
print "\n";
}
}
$i++;
}
print Dumper(%calrssi);
Thanks,
Sekar
Paul Lalli wrote:
> doni wrote:
> > Paul,
>
> Bzzt. That's three. You're out. You were asked repeatedly to stop
> top posting. You don't care about this simple request, I don't care
> about helping you. Bye.
>
> Paul Lalli
------------------------------
Date: 21 Sep 2006 20:00:26 GMT
From: Glenn Jackman <glennj@ncf.ca>
Subject: Re: extracting inner key from a hash of hashes
Message-Id: <slrneh5rqr.218.glennj@smeagol.ncf.ca>
At 2006-09-21 03:27PM, "doni" wrote:
> print Dumper(%calrssi);
The Dumper function takes a list of scalars. If you want to dump a hash
(or array) pass a reference instead:
print Dumper(\%calrssi);
An example:
$ perl -MData::Dumper -e '
%test=(a=>1,b=>{c=>2,d=>3,e=>[4,5,6,7]},f=>"g");
# vvv
print "properly\n", Dumper(\%test), "\n";
print "improperly\n", Dumper(%test), "\n";
# ^^^
'
properly
$VAR1 = {
'a' => 1,
'b' => {
'e' => [
4,
5,
6,
7
],
'c' => 2,
'd' => 3
},
'f' => 'g'
};
improperly
$VAR1 = 'a';
$VAR2 = 1;
$VAR3 = 'b';
$VAR4 = {
'e' => [
4,
5,
6,
7
],
'c' => 2,
'd' => 3
};
$VAR5 = 'f';
$VAR6 = 'g';
--
Glenn Jackman
Ulterior Designer
------------------------------
Date: Thu, 21 Sep 2006 21:38:05 +0100
From: David Squire <David.Squire@no.spam.from.here.au>
Subject: Re: extracting inner key from a hash of hashes
Message-Id: <eeut6e$ri9$1@gemini.csx.cam.ac.uk>
Paul Lalli wrote:
> David Squire wrote:
>>
>> Ermm... how does this correspond to you original question, which seemed
>> to be about a single hash that in turn contained other hashes, etc. Here
>> you show eight separate variables, some of which are plain scalars, and
>> others which are hash references.
>
> Oh come on. David, you know full well that in this case, the OP simply
> passed %hash to Dumper(), rather than \%hash. Let's not be too
> snippity, shall we?
>
Fair enough. I should take more care not to reveal by being tired and
snippy in the world in the world of usenet :)
DS
------------------------------
Date: 21 Sep 2006 13:44:37 -0700
From: "doni" <doni.sekar@gmail.com>
Subject: Re: extracting inner key from a hash of hashes
Message-Id: <1158871476.830247.198500@k70g2000cwa.googlegroups.com>
thanks glen, now I got the dumper outputting hash properly.
I tried your dereferencing option and it also worked fine.
Thanks,
Sekar
your my @mac_address1_destinations = keys %{ $hash{mac-address1} };
Thanks,
sekar
Glenn Jackman wrote:
> At 2006-09-21 03:27PM, "doni" wrote:
> > print Dumper(%calrssi);
>
> The Dumper function takes a list of scalars. If you want to dump a hash
> (or array) pass a reference instead:
>
> print Dumper(\%calrssi);
>
> An example:
>
> $ perl -MData::Dumper -e '
> %test=(a=>1,b=>{c=>2,d=>3,e=>[4,5,6,7]},f=>"g");
> # vvv
> print "properly\n", Dumper(\%test), "\n";
> print "improperly\n", Dumper(%test), "\n";
> # ^^^
> '
> properly
> $VAR1 = {
> 'a' => 1,
> 'b' => {
> 'e' => [
> 4,
> 5,
> 6,
> 7
> ],
> 'c' => 2,
> 'd' => 3
> },
> 'f' => 'g'
> };
>
> improperly
> $VAR1 = 'a';
> $VAR2 = 1;
> $VAR3 = 'b';
> $VAR4 = {
> 'e' => [
> 4,
> 5,
> 6,
> 7
> ],
> 'c' => 2,
> 'd' => 3
> };
> $VAR5 = 'f';
> $VAR6 = 'g';
>
> --
> Glenn Jackman
> Ulterior Designer
------------------------------
Date: 21 Sep 2006 13:44:50 -0700
From: "doni" <doni.sekar@gmail.com>
Subject: Re: extracting inner key from a hash of hashes
Message-Id: <1158871490.584428.294800@i42g2000cwa.googlegroups.com>
thanks glen, now I got the dumper outputting hash properly.
I tried your dereferencing option and it also worked fine.
Thanks,
Sekar
Glenn Jackman wrote:
> At 2006-09-21 03:27PM, "doni" wrote:
> > print Dumper(%calrssi);
>
> The Dumper function takes a list of scalars. If you want to dump a hash
> (or array) pass a reference instead:
>
> print Dumper(\%calrssi);
>
> An example:
>
> $ perl -MData::Dumper -e '
> %test=(a=>1,b=>{c=>2,d=>3,e=>[4,5,6,7]},f=>"g");
> # vvv
> print "properly\n", Dumper(\%test), "\n";
> print "improperly\n", Dumper(%test), "\n";
> # ^^^
> '
> properly
> $VAR1 = {
> 'a' => 1,
> 'b' => {
> 'e' => [
> 4,
> 5,
> 6,
> 7
> ],
> 'c' => 2,
> 'd' => 3
> },
> 'f' => 'g'
> };
>
> improperly
> $VAR1 = 'a';
> $VAR2 = 1;
> $VAR3 = 'b';
> $VAR4 = {
> 'e' => [
> 4,
> 5,
> 6,
> 7
> ],
> 'c' => 2,
> 'd' => 3
> };
> $VAR5 = 'f';
> $VAR6 = 'g';
>
> --
> Glenn Jackman
> Ulterior Designer
------------------------------
Date: Thu, 21 Sep 2006 18:27:10 GMT
From: ed <ed@noreply.com>
Subject: Re: hashes question
Message-Id: <20060921192554.4bec3936@localhost.localdomain>
On Wed, 20 Sep 2006 22:31:53 GMT
"John W. Krahn" <someone@example.com> wrote:
> ed wrote:
> > I'm having a bit of trouble sending hash elements to sub routines
> > and back.
> >
> > Any help appreciated!
> >
> > sub entry {
> > my $l = shift;
> > my %h = %_;
> >
> > while( ( my $k, my $v ) = each ( %h ) ) {
> > print( "K: $k V: $v\n" );
> > }
> > return(%h);
> > }
> >
> > $h{'stuff'} = "hello";
> > %h = entry( "1", \%h );
> >
> > When run %h becomes empty in entry.
>
> You are calling entry() with a hash reference so you have to
> dereference it inside the sub:
>
> sub entry {
> my $l = shift;
> my $h = shift;
>
> while( my ( $k, $v ) = each ( %$h ) ) {
> print( "K: $k V: $v\n" );
> }
> return %h;
> }
Thank you all very much, Abigail, David and Tad. Problem solved. This
was a very difficult problem for me, I would never have solved it alone.
--
Regards, Ed :: http://www.linuxwarez.co.uk
proud bash person
When Chuck Norris roundhouse kicks people, they do not die of blunt
trauma or tissue damage. They simple lose their will to live.
------------------------------
Date: Thu, 21 Sep 2006 21:26:19 GMT
From: "Mumia W. (reading news)" <paduille.4058.mumia.w@earthlink.net>
Subject: Re: Help with plotting
Message-Id: <%rDQg.10590$v%4.6911@newsread1.news.pas.earthlink.net>
On 09/21/2006 11:11 AM, Deepu wrote:
> Thanks a lot for the help. I tried the below code and am getting an
> error like:
>
> Can't locate PDL/Graphics/PLplot.pm in @INC
>
> Can somebody please let me know what changes need to be done.
>
> Thanks
>
If you're using Windows ActiveState Perl, use ppm to install both PDL
and PDL::Graphics::PLplot. If they won't install, I hear that there is a
very competently run module repository called theory5 (I don't have the
link) that has many modules that aren't provided by ActiveState corporation.
I'm lucky to be using Debian. Debian Linux is probably the biggest
collection of free software in existence, and PDL::Graphics::PLplot is
included in Debian as part of Debian's "pdl" package.
--
paduille.4058.mumia.w@earthlink.net
------------------------------
Date: 21 Sep 2006 20:17:54 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: How do I find the Nth index of array that is (whatever)
Message-Id: <g8b5h2lepfa2me9k8iro2fduefr419ubhn@4ax.com>
On Thu, 21 Sep 2006 12:43:38 +0200, Mirco Wahab
<peace.is.our.profession@gmx.de> wrote:
>But the (your) 'indexing+grep' combination:
>
> my $loc = nth_occurence_of_false;
> my ($index) = grep !$array[$_] && !--$loc, 0..$#array;
>
>looks to me like the most beautiful,
>maybe 'idiomatic' solution.
You/we're using $loc to do our own indexing/subscripting, whereas Perl
provides means specifically aimed at that job. But more importantly it
still bothers me that it does more stuff than necessary. Thus in a
context in which it's relevant, I'd use an explicit loop with a means
to leave the latter early; in one in which it isn't, grep() and
subscripting.
Michele
--
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
.'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,
------------------------------
Date: 21 Sep 2006 20:17:55 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: How do I find the Nth index of array that is (whatever)
Message-Id: <0jb5h25ofu1asval7rn7haj88oki6jed3r@4ax.com>
On Thu, 21 Sep 2006 08:03:07 -0500, Tad McClellan
<tadmc@augustmail.com> wrote:
>> but it's lighter IMHO.
>
>
>But it introduces "startle factor" that would not be there if you
>instead chose to use parenthesis around this function's argument list.
>
>It is lighter for development, but much heavier for maintenance...
I'm easily distracted by unncessary parens. If there are nested ones,
my editor helps me matching them, but still I find them visually
confusing. Avoiding them doesn't make maintenance any heavier. I'm not
claiming all this has a universal value, though. Indeed there's been a
time I've been surprised myself by this particular syntax. Now I'd
call it a common perl idiom.
Michele
--
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
.'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc. For subscription or unsubscription requests, send
#the single line:
#
# subscribe perl-users
#or:
# unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.
#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V10 Issue 9751
***************************************