Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re^3: detecting an undefined variable

by Haarg (Priest)
on Sep 21, 2019 at 20:45 UTC ( [id://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 (Saint) 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?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (7)
As of 2024-04-19 12:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found