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().