-   Programming (
-   -   Perl: Condition?print "Is true":print "Is false"; (

angel115 09-17-2010 02:48 AM

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 ")?"

tshikose 09-17-2010 05:21 AM

Hi angel115,

Try the below in Perl.

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



angel115 09-17-2010 06:28 AM

It's working, Thanks.

All times are GMT -5. The time now is 06:50 PM.