dda
asked on
"or" vs "||"
What is the difference between "or" and "||" in general and in the following source particulary:
#!/usr/bin/perl -w
use strict;
my @allowed;
@allowed = fillnodes() or die "Error!\n";
print "@allowed\n";
@allowed = fillnodes() || die "Error!\n";
print "@allowed\n";
sub fillnodes {
my @nodes;
@nodes = (@nodes, 'first');
@nodes = (@nodes, 'second');
return @nodes;
}
#!/usr/bin/perl -w
use strict;
my @allowed;
@allowed = fillnodes() or die "Error!\n";
print "@allowed\n";
@allowed = fillnodes() || die "Error!\n";
print "@allowed\n";
sub fillnodes {
my @nodes;
@nodes = (@nodes, 'first');
@nodes = (@nodes, 'second');
return @nodes;
}
ASKER
Ok. Thanks.
ASKER
2ozo: Why do you leave this question unlocked?
I wanted to be sure the question was fully answered before locking.
I take it the difference is clear now?
perldoc perlop
also explains this
I take it the difference is clear now?
perldoc perlop
also explains this
ASKER
Yes, thanks. You helped greatly.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
@allowed = fillnodes() or die "Error!\n";
#parses as
(@allowed = fillnodes()) or die "Error!\n";
@allowed = fillnodes() || die "Error!\n";
#parses as
@allowed = (fillnodes() || die "Error!\n");