LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 06-12-2009, 03:24 PM   #1
hockeyman_102
Member
 
Registered: Apr 2006
Location: Washington
Distribution: Suse, CentOS, Ubuntu
Posts: 124

Rep: Reputation: 15
Angry perl not vs. !


This is retarded, I know, but I got hammered on today by my boss about using 'not' instead of a '!'. Does anyone have any in-depth knowledge on which is faster, better, smarter, etc.?

The snippit is below:

Code:
if(not defined $params{'cookie'}){
     # No cookie?  Give 'em one.
     ...
}
Thanks!
 
Old 06-12-2009, 03:58 PM   #2
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
A snippet from "Perl in a Nutshell"
Quote:
Unary ! performs logical negation, that is, "not." The not operator is a lower-precedence version of !.
And from the official Perl documentation:
Quote:
Unary "not" returns the logical negation of the expression to its right. It's the equivalent of "!" except for the very low precedence.

Last edited by colucix; 06-12-2009 at 03:59 PM.
 
Old 06-12-2009, 07:34 PM   #3
GaijinPunch
Member
 
Registered: Aug 2003
Location: Tokyo, Japan
Distribution: Gentoo
Posts: 130

Rep: Reputation: 22
It's probably better programming practice to use the universal '!' instead of the unary equivalent to boot. I know I like to remember as little as possible anyway.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Installing Eclipse, the Epic Perl plugin and my first Perl GUI program LXer Syndicated Linux News 0 05-08-2009 06:41 PM
RHEL4u2 perl localtime() call issues (perl & glibc) Brad.Scalio@noaa.gov Linux - Enterprise 3 01-23-2007 09:27 PM
perl(Cwd) perl(File::Basename) perl(File::Copy) perl(strict)....What are those? Baldorg Linux - Software 1 11-09-2003 08:09 PM
chrooting apache v2 (php, ssl, perl support) ; perl configuration markus1982 Linux - Security 3 01-26-2003 06:15 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 04:39 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration