Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Perl Misc (http://www.velocityreviews.com/forums/f67-perl-misc.html)
-   -   conditional (http://www.velocityreviews.com/forums/t891230-conditional.html)

man-wai chang 03-08-2005 11:12 AM

conditional
 
what's wrong with this line:

print (($found)? "" : "not")."found\n";


--
.~. Might, Courage, Vision. http://www.linux-sxs.org
/ v \
/( _ )\ Linux 2.4.29
^ ^ 7:11pm up 3 days 9:21 load average: 1.01 1.39 2.30

Anno Siegel 03-08-2005 11:21 AM

Re: conditional
 
man-wai chang <toylet@hotpop.com> wrote in comp.lang.perl.misc:
> what's wrong with this line:
>
> print (($found)? "" : "not")."found\n";


Consult the documentation of the functions you're using if they're giving
you trouble. perldoc -f print. See the sentence beginning with "Also
be careful...".

Anno

Arndt Jonasson 03-08-2005 11:25 AM

Re: conditional
 

man-wai chang <toylet@hotpop.com> writes:
> what's wrong with this line:
>
> print (($found)? "" : "not")."found\n";


If you enable warnings, you will get a very long and descriptive
text that tells you what the problem is.

man-wai chang 03-08-2005 12:59 PM

Re: conditional
 
> Consult the documentation of the functions you're using if they're giving
> you trouble. perldoc -f print. See the sentence beginning with "Also
> be careful...".


I see. thanks.

--
.~. Might, Courage, Vision. http://www.linux-sxs.org
/ v \
/( _ )\ Linux 2.4.29
^ ^ 8:59pm up 3 days 11:09 load average: 1.17 1.10 0.91

Tad McClellan 03-08-2005 01:40 PM

Re: conditional
 
man-wai chang <toylet@hotpop.com> wrote:

> what's wrong with this line:



It has too many parenthesis and a dot instead of a comma. :-)

(ie. precedence)


print $found ? '' : 'not', "found\n";


> print (($found)? "" : "not")."found\n";



You should always enable warnings when developing Perl code!

(Especially when perl is doing something you don't understand.

Especially especially before asking hundreds of people around
the world to help you with it.
)


See also:

Message-Id: <slrnatq036.2q2.tadmc@magna.augustmail.com>


--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas

man-wai chang 03-10-2005 02:03 AM

Re: conditional
 
> You should always enable warnings when developing Perl code!
>
> (Especially when perl is doing something you don't understand.


I used `perl -w`. What else do I need?

--
.~. Might, Courage, Vision. http://www.linux-sxs.org
/ v \
/( _ )\ Linux 2.4.29
^ ^ 10:02am up 15:16 1 user 1.53 1.30

Sherm Pendley 03-10-2005 02:42 AM

Re: conditional
 
man-wai chang wrote:

>> You should always enable warnings when developing Perl code!
>>
>> (Especially when perl is doing something you don't understand.

>
> I used `perl -w`. What else do I need?


sherm:~ sherm$ perl -e 'print (($found)? "" : "not")."found\n";'
not

sherm:~ sherm$ perl -w -e 'print (($found)? "" : "not")."found\n";'
print (...) interpreted as function at -e line 1.
Useless use of concatenation (.) or string in void context at -e line 1.
Name "main::found" used only once: possible typo at -e line 1.
not

You need to actually use it. Then, you need to read the warnings it
produces. If you don't understand them, try using diagnostics instead of
warnings, for a longer message:

perl -Mdiagnostics -e 'print (($found)? "" : "not")."found\n";'

sherm--

--
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org


All times are GMT. The time now is 12:33 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.