Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: How scoping works in If statements?

by mjemmeson (Monk)
on May 30, 2008 at 08:46 UTC ( #689156=note: print w/ replies, xml ) Need Help??


in reply to How scoping works in If statements?

if you want to assign conditionally only using one line try the ternary operator:

my $x = (1) ? 5 : undef;


Comment on Re: How scoping works in If statements?
Download Code
Re^2: How scoping works in If statements?
by kwaping (Priest) on May 30, 2008 at 18:17 UTC
    That still doesn't address the underlying scoping issue, though.
    use strict; use warnings; my $x = (0) ? 5 : undef; my $x = 42; __END__ "my" variable $x masks earlier declaration in same scope

    ---
    It's all fine and dandy until someone has to look at the code.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (10)
As of 2014-08-29 15:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (281 votes), past polls