Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: inheritance turns back and bites

by Abigail-II (Bishop)
on Mar 01, 2004 at 14:54 UTC ( #332931=note: print w/ replies, xml ) Need Help??


in reply to inheritance turns back and bites

Well, you can't modify constants. Your problem isn't any different than:

bless \42, "whatever";
or
sub foo {$_ [0] += 10} foo 42;
Furthermore, the use of bless \pop, shift; is questionable, as there's no order of evaluation defined for the comma in list context.

Abigail


Comment on Re: inheritance turns back and bites
Select or Download Code
Re: Re: inheritance turns back and bites
by ysth (Canon) on Mar 01, 2004 at 16:25 UTC
    That's what I thought at first glance, but after a moment realized that pop, shift on a 2+ element array is going to get the last and first elements regardless of order of evaluation.

    Nevertheless, it's a bad way to do it, since if the method call is given no parameters, the bless will default to package "main" (with a warning).

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://332931]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (7)
As of 2014-09-30 22:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (385 votes), past polls