conditional

Discussion in 'Perl Misc' started by man-wai chang, Mar 8, 2005.

  1. 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
     
    man-wai chang, Mar 8, 2005
    #1
    1. Advertising

  2. man-wai chang

    Anno Siegel Guest

    man-wai chang <> 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
     
    Anno Siegel, Mar 8, 2005
    #2
    1. Advertising

  3. man-wai chang <> 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.
     
    Arndt Jonasson, Mar 8, 2005
    #3
  4. > 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
     
    man-wai chang, Mar 8, 2005
    #4
  5. man-wai chang <> 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: <>


    --
    Tad McClellan SGML consulting
    Perl programming
    Fort Worth, Texas
     
    Tad McClellan, Mar 8, 2005
    #5
  6. > 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
     
    man-wai chang, Mar 10, 2005
    #6
  7. 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
     
    Sherm Pendley, Mar 10, 2005
    #7
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Chris P
    Replies:
    0
    Views:
    448
    Chris P
    Oct 28, 2003
  2. Willem Oosthuizen

    Conditional signal declaration

    Willem Oosthuizen, Jul 16, 2003, in forum: VHDL
    Replies:
    5
    Views:
    7,041
    Mario Trams
    Jul 17, 2003
  3. itsme
    Replies:
    1
    Views:
    1,692
    Ralf Hildebrandt
    Jul 23, 2003
  4. Anand P Paralkar
    Replies:
    2
    Views:
    9,552
    Srinivasan Venkataramanan
    Aug 4, 2003
  5. Alec S.
    Replies:
    10
    Views:
    10,333
    Alec S.
    Apr 16, 2005
Loading...

Share This Page