Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re^2: Ternary Operator with Subroutine

by egga (Monk)
on Aug 12, 2011 at 08:37 UTC ( [id://919997]=note: print w/replies, xml ) Need Help??


in reply to Re: Ternary Operator with Subroutine
in thread Ternary Operator with Subroutine

There must be something I didnt understand yet, so I excuse my question, dear Monks. But why would anyone would like to do that? Is there any possibility, that

my $test
may fail?

It seems to me like writing

if (1) { print "some"; } else { print "thing"; }
(And in that case, I could imagine some kind of debug-switch or so).

Please enlighten me.

Replies are listed 'Best First'.
Re^3: Ternary Operator with Subroutine
by BrowserUk (Patriarch) on Aug 12, 2011 at 08:48 UTC
    Is there any possibility, that my $test may fail?

    Actually, it will always "fail". That is, an uninitialised variable is always undef, and therefore false.

    It also doesn't make much sense to do print 'a'; print 'b'; instead of print 'a', 'b'; or print 'ab';.

    I think it is fair to assume that the code supplied it greatly simplified example and that ( my $test ) is just a placeholder for 'some boolean condition' rather than an actual variable declaration.


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://919997]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (3)
As of 2024-04-19 01:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found