conditional

A

Anno Siegel

man-wai chang said:
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
 
A

Arndt Jonasson

man-wai chang said:
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.
 
M

man-wai chang

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.
 
T

Tad McClellan

man-wai chang said:
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: <[email protected]>
 
M

man-wai chang

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?
 
S

Sherm Pendley

man-wai chang said:
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--
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top