What no one has said so far is the importance of using Carp when throwing
errors related to how the function was called. The Carp module provides
versions of warn (carp) and die (croak) that give the line and file where
the call to the function occurred rather than the line of the carp or croak:
On 19/11/17 13:57, hw wrote:
> without being able to use feature 'signatures', how do I verify
> that parameters passed to a function have been passed to it by
> the caller?
If you're dealing with positional parameters[1] (and not with named
ones) you can check for the size of @_ inside your
On 19/11/17 15:40, Gil Magno wrote:
> $num_of_params = scalar @_;
Complementing... In order to get the number of params, you could do
$num_of_params = @_;
without using "scalar @_", because this assignment is already in scalar
context.
But if you're in list context, you have to use
This is how I'd go about it:
https://gist.github.com/andrewsolomon/323a2b317ea5903f662fbaaded254798
"exists" is true if there's a key in a hash even if the key's value is
undef.
Does that provide a solution for you, or are there other constraints?
On Sun, Nov 19, 2017 at 4:57 PM, hw
Hi,
without being able to use feature 'signatures', how do I verify
that parameters passed to a function have been passed to it by
the caller?
A test for undef is not sufficient because the value passed to a
function may be undef itself, and I need to be able to distinguish
between the