Good info. thanks, -rkl
> Hi, > > [EMAIL PROTECTED] wrote: >> How do I pass a null variable as an argument? Sometime I may want a >> wrapper sub as below: >> >> Example, >> ... >> sub procName >> { my $fname = $_[0]; >> my $lname = $_[1]]; >> } > > Alternatively, you could write either > > my $fname = shift; > my $lname = shift; > > or even > > my( $fname, $lname ) = @_; > >> >> my procByLastName{ mySubA(null, "doe"); } >> ... >> >> This is the error message: >> Bareword "null" not allowed while "strict subs" in use > > Perl's notion of NULL would be undef, i.e. not defined. > As such, it's distinct from an empty string or zero as > a numeric value. > > The function defined() helps you to test wether a value > is undef or not. > > BTW, since you ask about argument passing and undef, > a nice way to handle setting defaults for arguments > is using this syntax: > > my $var = shift || "default"; > > Works great if your expected arguments are always > defined and true. It would set $var to "default" > if you pass in an empty string or the number 0, > though. > > HTH, > Thomas > ----------------------------------------- eMail solutions by http://www.swanmail.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]