?
Solved

"or" vs "||"

Posted on 1998-10-25
6
Medium Priority
?
213 Views
Last Modified: 2010-03-04
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;
}
0
Comment
Question by:dda
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 84

Expert Comment

by:ozo
ID: 1205700
#they differ in precedence

@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");
0
 
LVL 4

Author Comment

by:dda
ID: 1205701
Ok. Thanks.
0
 
LVL 4

Author Comment

by:dda
ID: 1205702
2ozo: Why do you leave this question unlocked?
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 84

Expert Comment

by:ozo
ID: 1205703
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
0
 
LVL 4

Author Comment

by:dda
ID: 1205704
Yes, thanks. You helped greatly.
0
 
LVL 84

Accepted Solution

by:
ozo earned 200 total points
ID: 1205705
#they differ in precedence

@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");
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question