Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Error in camel book 3

by Anarion (Hermit)
on Oct 03, 2001 at 14:03 UTC ( [id://116401]=perlmeditation: print w/replies, xml ) Need Help??

Mmmm i think that there is an error in camel book third edition,I looked if someone noticed before me, but i didnt find anything ...
Likewise, you can pass a reference into a subroutine and use it withou +t dereferencing: %units = (miles => 6, stones => 11); fillerup( \%units ); # Pass in a reference print $units{quarts}; # Prints 4 sub fillerup { local *hashsym = shift; # Assign \%units to the typeglob $hashsym{quarts} = 4; # Affects %units; no dereferencing neede +d! } These are tricky ways to pass around references cheaply when you don't + want to have to explicitly dereference them. Note that both techniqu +es only work with package variables; they would not have worked had w +e declared %units with my.

I have declare my %units and still working ....
Under use strict i have to declare our %hashsym, but still working again.
Im missing something or its an error?

$anarion=\$anarion;

s==q^QBY_^=,$_^=$[x7,print

Replies are listed 'Best First'.
Re: Error in camel book 3
by trantor (Chaplain) on Oct 03, 2001 at 16:08 UTC

    Since you can't localise a lexical, I think that

    they would not have worked had we declared %units with my
    should be read as
    they would not have worked had we declared %hashsym with my

    -- TMTOWTDI

Re: Error in camel book 3
by pixel (Scribe) on Oct 03, 2001 at 14:23 UTC

    If anyone else wants to investigate this, it's on p294 of the 3rd edition.

    It does seem to be a mistake as the example works just fine if %units is a lexical variable. Perhaps you should tell O'Reilly.

    Blessed Be
    The Pixel

Re: Error in camel book 3
by petral (Curate) on Oct 03, 2001 at 22:17 UTC
Re: Error in camel book 3
by Cine (Friar) on Oct 04, 2001 at 13:23 UTC
    Check out this node: 106017

    T I M T O W T D I

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlmeditation [id://116401]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (4)
As of 2024-04-20 04:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found