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

Re^5: accessing stashes

by ikegami (Pope)
on Mar 01, 2019 at 19:28 UTC ( #1230731=note: print w/replies, xml ) Need Help??


in reply to Re^4: accessing stashes
in thread accessing stashes

Main is %:: (or %main:: (or %main::main:: (...))) instead of %My::.

Replies are listed 'Best First'.
Re^6: accessing stashes
by morgon (Priest) on Mar 01, 2019 at 19:35 UTC
    I know that.

    But I want one expression to determine the condition, I want to avoid (for reasons of pure idiocy) to have an extra assignment...

    So something like

    print defined *main::{$symbol}->*{CODE} ? "yep": "nope";
    But I cannot do it...

      It's $glob && *$glob{CODE}, not defined *main::{$symbol}->*{CODE}.

        First of all thanks a lot for solving my problem.

        But I was wondering if there is an expression that would avoid having a two-step solution (i.e. without first assigning a temporary $glob variable).

        So is there an expression that when I have a symbol ("hubba" say) I could do a

        $some_convoluted_expression{hubba}->{CODE}
        (or something like that) to determine whether or not there is a sub-routine of that name in the main-package.

        But this is for bonus-points only...

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (1)
As of 2021-10-22 03:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My first memorable Perl project was:







    Results (85 votes). Check out past polls.

    Notices?