The @_ variable is an array that contains all the parameters passed into a subroutine. The parentheses around the $string variable are absolutely necessary. They designate that you are assigning variables from an array.
There is a strange scalar variable called $_ in Perl, which is the default variable, or in other words the topic. In Perl, several functions and operators use this variable as a default, in case no parameter is explicitly used.
-> will resolve inherited methods making it cleaner and more useful for objects. Foo->Bar(); Foo::Bar('Foo'); This means that -> is generally used in instance methods so that the object is passed its self and constructors so the constructors know which package to bless with.
Please explain what exactly the difference of $_
and @_
is in Perl.
When to use which, given by example code.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With