Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: Unexpected value in incoming variable.

by Coruscate (Sexton)
on Jan 10, 2004 at 06:39 UTC ( [id://320306]=note: print w/replies, xml ) Need Help??


in reply to Unexpected value in incoming variable.

Within a package, the first argument/parameter passed to a method is the package name, unless you are dealing with an object, in which case the first argument returned is the object itself. So to get your wanted results, you just need to add another variable capture:

package Alice; use strict; sub mTest2 { my ($self, $junk, $and) = @_; print "$junk=$junk\n\$and=$and"; }

Replies are listed 'Best First'.
Re: Re: Unexpected value in incoming variable.
by BUU (Prior) on Jan 10, 2004 at 06:58 UTC
    Within a package, the first argument/parameter passed to a method is the package name

    This is of course only true if you call the sub via the class syntax (either class->method or method class (how did you think new class worked?))

    If you just want a namespace and don't want to bother with package/object syntax then use double colons to delimit packages for your function call, as in Alice->method(); becomes Alice::method().

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (5)
As of 2024-04-19 20:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found