Welcome to WebProNews Breaking eBusiness and Search News
Advertise | Newsletter | Sitemap | News Feeds News Feed 
 WebProNews Search Part of the iEntry network iEntry inc. 

Perl Binding,

A.P. Lawrence
Expert Author
Published: 2005-10-25

WebProNews RSS Feed

Perl has "||" and "or". While "or" can't be used in bit operations, either one can be used in logical flow control - but there is an important difference between them.

For example, this code doesn't work properly:

open FILE, "$file" || die "Can't open: $! n";
print "$file open";

If "$file" doesn't exist, you won't get the "Can't open" message. The problem is that the "||" binds tightly and confuses the "open" function. You need to either do:

open FILE, "$file" or die "Can't open: $! n";

(because or binds less tightly than ||) or

open(FILE, "$file") || die "Can't open: $! n";

(because the parens contain the open function)

Generally speaking it's a very good idea for new Perl folk to use "or" rather than "||" in conditional flow tests, and to use parens for functions. So (following both rules), I'd recommend getting used to writing that like this:

open(FILE, "$file") or die "Can't open: $! n";

at least until you are very clear on what each of these does.

*Originally published at APLawrence.com

Receive Our Daily Email of Breaking eBusiness News

About the Author:
A.P. Lawrence provides SCO Unix and Linux consulting services http://www.pcunix.com

WebProNews RSS Feed

More Expert Articles Articles

Contact WebProNews


Targeted Information for Business
WebProNews is part of the iEntry network

Internet Business: Marketing: Small Business:
WebProNews MarketingNewz SmallBusinessNewz
WebProWorld AdvertisingDay PromoteNews
EcommNewz SalesNewz EntrepreneurNewz

Software: Search Engines: Web Design:
WebMasterFree Jayde B2B DesignNewz
NetworkingFiles SearchZA FlashNewz
SecurityConfig SearchNewz WebSiteNotes

Developer: IT Management: Security:
DevWebPro ITManagement SecurityProNews
DevNewz SysAdminNews SecurityConfig
TheDevWeb NetworkingFiles NetworkNewz

The iEntry Network consists of over 100 web publications reaching millions of Internet Professionals. Contact us to advertise.

 Advertise | Contact Us | Corporate | Newsletter | Sitemap | Submit an Article | News Feeds
 WebProNews is an iEntry, Inc. ® publication - $line) { echo $line ; } ?> All Rights Reserved
About WebProNews
WebProNews is the number one source for eBusiness News. Over 5 million eBusiness professionals read WebProNews and other iEntry business and tech publications.

WebProNews provides real-time coverage of internet business.

Free Email Newsletters:
WebProNews SearchNewz
WebProWorld DevWebPro
Marketing SecurityNews
Plus over 100 other newsletters!

Send me relevant info on products and services.

Ten most recent posts.

Featured Software

WebProNews in the News
View all recent mentions of WebProNews from around the world!

Recent Articles On ...
Google eBusiness
Yahoo Ask Jeeves
MSN Blogs
Search Engines Blogging
Affiliate Programs Marketing
eCommerce Advertising
eBay Sun Microsystems
AOL Adsense
Microsoft Adwords
Oracle IBM
Amazon Apple
SEO iPod
Adsense XBox
PR Adobe

iEntry.com WebProWorld RSS Feed WebProWorld Contact WebProNews Print Version Email a friend Bookmark us