I'm trying to test for a parameter with shift or die.
The parameter in this case is zero, so I am wary of dodgy true/false interpretations on my part. However, with @_ being three items long, shift populates the variable it is supposed to and then dies as well.
Why?
Is it because shift is returning zero which is evaluating to false? I was expecting shift to return success if it could shift an item.
Is there an alternative operator I could use or some conbination of shift / defined?
#!/usr/local/bin/perl -w
use strict;
lookup(22);
lookup(22, 'data');
my $var = 111;
lookup(22, 'data', $var);
$var = 0;
lookup(22, 'data', $var);
sub lookup {
print "Num params", scalar (@_), "\n";
my $self = shift;
my $data_type = shift or print "type not provided ConfReaderlookup
+\n";
my $item = shift or print "item not provided ConfReaderlookup
+\n";
print "ITEM isnt in here actually\n" unless defined $item;
print "----------------------------\n";
}