in reply to passing a scalar to a function
You can't do it the way you do. It would have helped if you showed us the warning you got too.
You seem to want to pass around parameters in the global $_ variable instead of using the common way of passing parameters in the function call, which populates @_. I guess that that's just a typo by you.
The best approach to check for parameters is the following:
sub mycheck { if (@_ == 0) { # No parameters passed, assume default @_ = (''); }; my ($db) = @_; ... };
... but you could also set up some other ways, depending on how your default works:
sub mycheck { my ($db) = @_; $db = "" unless defined $db; # will always map undef to '' ... };
|
|---|