Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

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 (Sage) 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
Domain Nodelet?
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 rifling through the Monastery: (1)
As of 2021-10-26 18:13 GMT
Find Nodes?
    Voting Booth?
    My first memorable Perl project was:

    Results (90 votes). Check out past polls.