Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

Re^3: detecting an undefined variable

by Haarg (Curate)
on Sep 21, 2019 at 20:45 UTC ( #11106513=note: print w/replies, xml ) Need Help??

in reply to Re^2: detecting an undefined variable
in thread detecting an undefined variable

That doesn't check if the variable exists though, it checks if the stash for that name is populated with anything. Having a sub or file handle with the same name would cause the stash entry to exist, usually stored inside a GLOB. While the other types can be detected, it isn't possible to distinguish between an undefined and non-existent scalar by inspecting a GLOB in pure perl.

Replies are listed 'Best First'.
Re^4: detecting an undefined variable
by LanX (Cardinal) on Sep 21, 2019 at 21:20 UTC
    You are right, exists doesn't work reliably on glob-slots. :/

    I should have known better, already got bitten by it in the past.

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery FootballPerl is like chess, only without the dice

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (5)
As of 2020-10-29 14:40 GMT
Find Nodes?
    Voting Booth?
    My favourite web site is:

    Results (271 votes). Check out past polls.