Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: how to call a sub via variable in library

by kennethk (Abbot)
on Nov 17, 2014 at 19:04 UTC ( [id://1107455]=note: print w/replies, xml ) Need Help??


in reply to how to call a sub via variable in library

$self->{&{\&{$testname}}}->($system); #system is hashref
...
Use of uninitialized value $self in concatenation (.) or string Can't call method "_idown" on an undefined value Can't call method "_idown" on an undefined value
The errors suggest that at some point you are invoking one of your methods without argument, thus $self is never initialized. Carp can be very helpful here for recovering the call stack where the error is actually happening, in the calling routine. You could also manually construct a relevant error using caller:
sub method { my $self = shift or die join(", ", caller()), "\n"; ... }

If I've misdiagnosed the issue (which is plausible given how complex your invocation is), you probably want to learn How can I visualize my complex data structure?.


#11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.

Replies are listed 'Best First'.
Re^2: how to call a sub via variable in library
by Anonymous Monk on Nov 17, 2014 at 19:09 UTC
    $self is perhaps initialized, but
    no strict 'refs'; $self->{ &{$testcase} }
    (I mean, the original, obfuscated version) is probably undef... But I'm no going to read this code any futher, frankly.
      That was my original thought, and then I saw Use of uninitialized value $self in concatenation (.) or string That's why I think my $self = shift or confess '$self undef'; is probably the best bet. I should point out that the $self that is uninitialized may not be the $self in the grotesque expression above.

      #11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (8)
As of 2024-04-23 17:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found