Do these regular calls to the Perl routines?

I'm still trying to understand the features of Perl OOP. I'm confused by something if I have a subroutine call like:

My::Package::sub_name($param1,$param2)

Will this get "My :: Package" as the first parameter? I would say no, but I'm not sure.

+3
source share
2 answers

Why don't you just give it a try?

Spoiler warning:

No, the first parameter will not be the package name.

However, when you do this:

My::Package->sub_name( $param1, $param2 )

you will get the package / class name as the first parameter.

+8
source

( ) -> operator, invocant @_ ( invocant - ). :: @_.

Geo, -:)

: perldoc perlboot, perldoc perltoot.

+10

Source: https://habr.com/ru/post/1721128/


All Articles