Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 09-17-2010, 03:48 AM   #1
Registered: Jul 2005
Location: France / Ireland
Distribution: Debian mainly, and Ubuntu
Posts: 535

Rep: Reputation: 79
Perl: Condition?print "Is true":print "Is false";

Hello There,

I was wondering if perl got the equivalent of php for the coditional check below:
Condition?print "true":print "false";

isset($_)?print "$_":print "\$_ is not set";
When I try to use it it give my the following error:
syntax error at ./shutdown_all line 33, near ")?"

Last edited by angel115; 09-17-2010 at 03:51 AM.
Old 09-17-2010, 06:21 AM   #2
Registered: Apr 2010
Location: Kinshasa, Democratic Republic of Congo
Distribution: RHEL, Fedora, CentOS
Posts: 404

Rep: Reputation: 73
Hi angel115,

Try the below in Perl.

print defined($_)? "$_": "\$_ is not defined";


Old 09-17-2010, 07:28 AM   #3
Registered: Jul 2005
Location: France / Ireland
Distribution: Debian mainly, and Ubuntu
Posts: 535

Original Poster
Rep: Reputation: 79
It's working, Thanks.


check, evaluation, perl

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
Trying to find libmail-mbox-messageparser-perl and libmailtools-perl for Fedora 11 almac58 Linux - Software 4 11-18-2009 04:17 AM
LXer: Installing Eclipse, the Epic Perl plugin and my first Perl GUI program LXer Syndicated Linux News 0 05-08-2009 07:41 PM
RHEL4u2 perl localtime() call issues (perl & glibc) Linux - Enterprise 3 01-23-2007 10:27 PM
perl(Cwd) perl(File::Basename) perl(File::Copy) perl(strict)....What are those? Baldorg Linux - Software 1 11-09-2003 09:09 PM
chrooting apache v2 (php, ssl, perl support) ; perl configuration markus1982 Linux - Security 3 01-26-2003 07:15 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:34 PM.

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