in reply to [SOLVED]: Trying to understand method calling in OOP

How did "Cow" become an argument when I didn't specify it anywhere?

That's what The Arrow Operator does. From "Method Invocation" in perlobj:

When you call a method, the thing on the left side of the arrow is passed as the first argument to the method. That means when we call Critter->new(), the new() method receives the string "Critter" as its first argument. When we call $fred->speak(), the $fred variable is passed as the first argument to speak().

Replies are listed 'Best First'.
Re^2: Trying to understand method calling in OOP
by Anonymous Monk on May 07, 2018 at 21:48 UTC
    Which is why the first line in many routines is my self = shift;

      Is that why?

      moo@cow[4345]~>perl -Mstrict -le 'sub { my self = shift }' No such class self at -e line 1, near "{ my self" syntax error at -e line 1, near "my self =" Execution of -e aborted due to compilation errors.

        I love it when I get to say "Your Mother has spoken!" ;)

      I tried my sundialsvc = shift; Doesn't work neither. Perl is magic.

      «The Crux of the Biscuit is the Apostrophe»

      perl -MCrypt::CBC -E 'say Crypt::CBC->new(-key=>'kgb',-cipher=>"Blowfish")->decrypt_hex($ENV{KARL});'Help