agoth has asked for the wisdom of the Perl Monks concerning the following question:
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"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: shift, undef and 'or die'
by arturo (Vicar) on Jul 26, 2001 at 18:01 UTC | |
|
Re: shift, undef and 'or die'
by tadman (Prior) on Jul 26, 2001 at 18:15 UTC | |
|
Re: shift, undef and 'or die'
by dragonchild (Archbishop) on Jul 26, 2001 at 18:07 UTC | |
|
(tye)Re: shift, undef and 'or die'
by tye (Sage) on Jul 26, 2001 at 20:18 UTC | |
|
Re: shift, undef and 'or die'
by ariels (Curate) on Jul 26, 2001 at 18:29 UTC |