in reply to Evil Interview Questions

It's humbling to see the gaps in my perl knowledge. I got three right, two wrong, and in the first example I had answered something different, don't know if you'd count that as right or wrong.
$self->foo(); foo($self);

I'd say that the main difference is where the perl interpreter searches for foo: in the first case it searches in $selfs package, in the second it searches in the current package.

Naming the variable $self suggests that they are identical, but that could be another of your evil tricks!

Replies are listed 'Best First'.
Re^2: Evil Interview Questions
by Jenda (Abbot) on Feb 08, 2008 at 23:47 UTC

    I'd count that as right,

    though I'd like to hear that in case of $self->foo() the foo is searched first in the $self's package and then in the packages in it's @ISA. In both cases the function that gets called receives $self as it's only parameter.

Re^2: Evil Interview Questions
by kyle (Abbot) on Feb 09, 2008 at 04:15 UTC

    I think your answer is correct. My own answer looks at it from the perspective of where you might notice a difference in a real program. I think your explanation says more about how that difference arises (i.e., how it all works).