in reply to Use of uninitialized value $var in pattern match (m//)
The error is pretty self-describing. $var contains undef. If you don't want undef to be passed to the invocation of $funct, you can find out where it is passed by using:
use Carp 'croak'; my $funct= sub { my $var= shift; croak '$var was passed an uninitialized value' if not defined $var; ... };
Note that the prototype on the subroutine won't help anything because a prototype only influences how Perl parses source code and Perl does not know where the value of $funct is used to call a function. I would leave the prototype off.
|
|---|