http://www.perlmonks.org?node_id=993560


in reply to sub argument passing? (TIMTOWTDI)

I did, however, encounter a snag with this method. I have to check for existence of the key within the referenced hash before attempting to access it otherwise Perl warns me about accessing an uninitialized value if the argument was not set by the user

If the caller doesn't pass the values you expect, you'll get a warning in the traditional style too:

$ perl -wE 'sub f { my ($v) = @_; say $v }; f()' Use of uninitialized value $v in say at -e line 1. $

In the end the level of checking you want to do is a matter of style, and intended audience.

In Perl 5 code I usually only check the arguments where I suspect the subs might get called wrongly. In Perl 6 I just write the signatures as expressive as possible, and let the compiler and runtime do the checking for me.