The light is beginning to shine a little brighter...
Joseph's cogent explanation of dereferencing is helpful. Thanks.
Yesterday I went out and bought the 3rd edition to the Perl reference book by
ORA (mine was a very old 1st edition). The 3rd edition has a whole lot more
on references than the
deb wrote:
> I'm not sure what you're saying. Since this is an anonymous hash assignment,
> how do I pull out the $listkey? Do I need to pre-assign it? For example,
> I tried this, added to the previous program,
>
> foreach $listname (sort keys %Lists) {
Thanks, Steve, for your feedback. As I said in private email to Steve
earlier today, I don't mind someone thumping the FM to me - problem is, I've
been reading all the FM I could find, including all those mentioned here.
Got the printouts right in front of me.
But I've been confused by different
Deb <[EMAIL PROTECTED]> writes:
>
> I understand this:
>
> foreach $listname (sort keys %Lists) {
> print "$listname\n";
> }
>
> But, I don't quite get how to get to the key values
> below that. I know I'm so close, but just not quite
> there...
>
> Could some kind soul give me a blow by
Deb wrote:
> You know, I'm just not "getting it" I guess. When I read through
> simple of examples in perldsc and perlfunc, it seems straightforward
> enough, but when I try to put into practice everything, it doesn't go
> as I might expect.
>
> Recall this code I posted a day or two ago:
>
> -
I'm not sure what you're saying. Since this is an anonymous hash assignment,
how do I pull out the $listkey? Do I need to pre-assign it? For example,
I tried this, added to the previous program,
foreach $listname (sort keys %Lists) {
print "$listname:\n";
foreach $k
-->8-
"I understand this:
foreach $listname (sort keys %Lists) {
print "$listname\n";
}
-->8-
To get the values instead of the keys, you will have to do something like
this:
foreach $listkey (sort keys %Lists){
print "$List
You know, I'm just not "getting it" I guess. When I read through
simple of examples in perldsc and perlfunc, it seems straightforward
enough, but when I try to put into practice everything, it doesn't go
as I might expect.
Recall this code I posted a day or two ago:
8-< -- snip
Deb wrote:
> Thanks for the quick reply...
>
> Okay, I could use Data::Dumper, but what do you mean by empty
> leading field? Am I dense? (probably!)
>
> I don't really want to use D::D module, so what would I do to
> alleviate this? Ensure no leading white space? I'll have to
> give that a try
All,
Replying to my own post - yup, that did it. I removed the leading
space(s), then did the hash ref assignment, and all was well.
Whew!
Thanks for the tip - and the pointer that I should have checked the
docs... sometimes the problem is that I'm just not sure *which* doc
would have the inf
tenr
> > list-3: -x fel -h asci
> > list-4: -x foo -h nonasci -r bfab
> >=20
> > I'm getting this output:
> >=20
> > Listname is list-1,
> > Field is: -x abc -r tenb
> > Odd number of elements in hash assignment ...
>=20
> You're
gt; $Lists{$listname} = \%hrLists;
> }
>
> __DATA__
> list-1: -x abc -r tenb
> list-2: -x def -r ghi -h tenr
> list-3: -x fel -h asci
> list-4: -x foo -h nonasci -r bfab
>
> I'm getting this output:
>
> Listname is list-1,
> Field is: -x abc -r tenb
> Odd
ame is list-1,
Field is: -x abc -r tenb
Odd number of elements in hash assignment at testhash2.pl line 52, line 1.
Listname is list-2,
Field is: -x def -r ghi -h tenr
Odd number of elements in hash assignment at testhash2.pl line 52, line 2.
Listname is list-3,
Field is: -x fel -h asci
Odd n
On Fri, 18 Jan 2002, [iso-8859-1] amrit kumar wrote:
> hi,
>
> what i want to proove is...supposer that i assign an
> array @a = (1,2); and then i define another array @b
> which is equal to @a.I have to proove that this is
> done by assigning a copy of array @a to @b rather than
> by refere
On Jan 18, amrit kumar said:
>what i want to proove is...supposer that i assign an
>array @a = (1,2); and then i define another array @b
>which is equal to @a.I have to proove that this is
>done by assigning a copy of array @a to @b rather than
>by reference.
To determine if two variables point
7;s not a reference
> }
>
> Rob
>
> -Original Message-
> From: amrit kumar [mailto:[EMAIL PROTECTED]]
> Sent: Friday, January 18, 2002 6:14 PM
> To: [EMAIL PROTECTED]
> Subject: array and hash assignment
>
>
> hi,
>
> howto to proove that array
D]
Subject: array and hash assignment
hi,
howto to proove that array and hash assignments are
made by using cloning and not by reference in perl.
I am a newbie at perl and have no idea howoto to do
it.
need help
have a good day
chee
hi,
howto to proove that array and hash assignments are
made by using cloning and not by reference in perl.
I am a newbie at perl and have no idea howoto to do
it.
need help
have a good day
cheers,
amrit.
__
Do You Yahoo!?
Everything
Hi,
I'm creating a hash like this:
%h = (a => 1, b => 2);
I want to also be able to define a key 'c' in terms of value in a and b.
I can do it in two lines:
%h = (a => 1, b => 2);
$h{c} = $h{a} + $h{b};
Is there any way to do this when creating the hash?
%h = (a => 1, b => 2, c => a + b)
I've
On Wed, Sep 19, 2001 at 04:20:25PM -0400, Bradshaw, Brian wrote:
>
> As for the for loop, well, I may get that advanced some time.
A for loop, or a foreach, is not advanced; it's very basic Perl. If your
learning material didn't impress upon you the usefullness or usability of
these constructs
;ve got is working...
John
-Original Message-
From: Bradshaw, Brian [mailto:[EMAIL PROTECTED]]
Sent: 17 September 2001 17:07
To: [EMAIL PROTECTED]
Subject: RE: hash assignment question
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
...
}
But if what you've got is working...
John
-Original Message-
From: Bradshaw, Brian [mailto:[EMAIL PROTECTED]]
Sent: 17 September 2001 17:07
To: [EMAIL PROTECTED]
Subject: RE: hash assignment question
This did it. I defined the hash and then did the key/value assignme
ever, in "if($vars{vNameL}) {" what does the $vars do? I have not seen
that.
-Original Message-
From: Brett W. McCoy [mailto:[EMAIL PROTECTED]]
Sent: Monday, September 17, 2001 11:04 AM
To: Bradshaw, Brian
Cc: [EMAIL PROTECTED]
Subject: Re: hash assignment question
The way you are doi
On Mon, 17 Sep 2001, Bradshaw, Brian wrote:
> I am trying to assign key/value pairs to a hash based on whether a variable
> from an HTML form has a value or not.
>
> I have the code:
> if ($vSalutation)
> {
> %arr_criteria = ("salutation" => $vSalutation);
> print "\n";
> print "Salutation:
uot;\n";
print "Last Name:";
print " $vNameL \n";
print "\n";
}
-Original Message-
From: Bradshaw, Brian [mailto:[EMAIL PROTECTED]]
Sent: 17 September 2001 15:44
To: [EMAIL PROTECTED]
Subject: hash assignment question
Hi List,
I am trying to assign
Hi List,
I am trying to assign key/value pairs to a hash based on whether a variable
from an HTML form has a value or not.
I have the code:
if ($vSalutation)
{
%arr_criteria = ("salutation" => $vSalutation);
print "\n";
print "Salutation:";
print " $vSalutation \n";
print "\n";
}
if ($
26 matches
Mail list logo