shift returns the value of the first entry in the array (or undef if there's nothing left in the array). So your surmise is right, if it's 0 it evaluates to false.
use some variant on my $data_type; print $errmsg unless defined ($data_type = shift); to get the behavior you want.
update even that may not be totally correct; undef is a valid value for an entry in an array which may have more members -- the fact that shift returns undef does not guarantee that you've hit the end of the array -- so you may want to check both the size of the argument array and the definedness of its members, if your purposes require that.
HTH.
perl -e 'print "How sweet does a rose smell? "; chomp ($n = <STDIN>); +$rose = "smells sweet to degree $n"; *other_name = *rose; print "$oth +er_name\n"'
In reply to Re: shift, undef and 'or die'
by arturo
in thread shift, undef and 'or die'
by agoth
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |