DekGenius.com
[ Team LiB ] Previous Section Next Section

8.9 What to Do with @_

In that last example, had there been any additional parameters to the speak routine (like how many times, or in what pitch for singing, for example), the parameters would be ignored by the Mouse::speak routine. If you want them to be passed uninterpreted to the parent class, you can add it as a parameter:

$class->SUPER::speak(@_);

This invokes the speak routine of the parent class, including all the parameters that you've not yet shifted off of your parameter list.

Which one is correct? It depends. If you are writing a class that simply adds to some of the parent class behavior, it's best to simply pass along arguments you haven't dealt with. However, if you want precise control over the parent class behavior, you should determine the argument list explicitly, and pass it.

    [ Team LiB ] Previous Section Next Section