Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > questions re "Using the Arrow Operator" in Camel 3ed

Reply
Thread Tools

questions re "Using the Arrow Operator" in Camel 3ed

 
 
Unknown Poster
Guest
Posts: n/a
 
      05-24-2004
I've read this section (page 253 of the 3rd edition of Programming Perl)
enough to confuse myself quite nicely.

One sentence reads, "If the next thing after the arrow is a bracket or a
brace, the left operand is treated as a reference to an array or hash,
respectively ..."

I just don't see how this code, and its explanation, square with that quote:

print $array[3]->{"English"}->[0];

" ... the fourth element of @array is intended to be a hash reference ..."

Isn't it the fourth element of the array referenced by (the poorly named)
$array ?


When there is more than one arrow operator in an expression, is it true
that only the "initial funny character" is omitted?

When the arrow operator is removed when it would be "between brackets
or braces, or between a closing bracket or brace and a parenthesis for
an indirect function call", is the meaning of the expression changed
in any way?

Anyone know what is meant by "ordinary arrays"?

I'll admit to be so baffled by the final "listref" expressions in this
section that I can't think of a good question.
 
Reply With Quote
 
 
 
 
Eric Bohlman
Guest
Posts: n/a
 
      05-24-2004
(Unknown Poster) wrote in
news: om:

> I've read this section (page 253 of the 3rd edition of Programming
> Perl) enough to confuse myself quite nicely.
>
> One sentence reads, "If the next thing after the arrow is a bracket or
> a brace, the left operand is treated as a reference to an array or
> hash, respectively ..."
>
> I just don't see how this code, and its explanation, square with that
> quote:
>
> print $array[3]->{"English"}->[0];
>
> " ... the fourth element of @array is intended to be a hash reference
> ..."
>
> Isn't it the fourth element of the array referenced by (the poorly
> named) $array ?


Nope. "$array" all by itself refers to a scalar variable that has nothing
to do with @array. "$array[3]", OTOH, means "the fourth element of
@array". It's followed by an arrow, and then an opening brace so, voila!
it's treated as a reference to a hash. This means that
"$array[3]->{"English"}" will be whatever value the hash being referenced
has for the key "English". And that in turn is followed by an arrow
followed by a bracket, so the hash value is now treated as a reference to
an array (which almost certainly isn't @array), and the whole expression
retrieves the value of the first element of that array.

> When there is more than one arrow operator in an expression, is it
> true that only the "initial funny character" is omitted?
>
> When the arrow operator is removed when it would be "between brackets
> or braces, or between a closing bracket or brace and a parenthesis for
> an indirect function call", is the meaning of the expression changed
> in any way?


No.

> Anyone know what is meant by "ordinary arrays"?


The kind of array that you name "@array" or "@emails" or what have you.

> I'll admit to be so baffled by the final "listref" expressions in this
> section that I can't think of a good question.


perldoc perlreftut might help unconfuse you.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Balenciaga "Giant Part Time" Bag Camel 084328A Collection bagsbags131@gmail.com Digital Photography 0 02-12-2009 09:10 AM
GSM and GPRS,CAMEL, INAP ,camel tutorials Ahsan UK VOIP 0 09-18-2006 07:59 AM
Synonyms for camel toe =?ISO-8859-1?Q?R=F4g=EAr?= Computer Support 5 09-29-2005 02:05 AM
DVD Verdict reviews: SWIMMING UPSTREAM, IT'S EASIER FOR A CAMEL..., and more! DVD Verdict DVD Video 0 09-09-2005 08:12 AM
DVD Verdict reviews: THE STORY OF THE WEEPING CAMEL and more! DVD Verdict DVD Video 0 04-18-2005 08:12 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57