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

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

OK, so Dumper output $VAR1 = \''; shows that $self->{_exit} is not a code ref, as expected. You haven't shown the code of Hitachi::Raidcom::exit_routine, but with the error message and Dumper output, it is reasonably clear what is happening.

Your code samples seem to be alternating between exit => \&Hitachi::Raidcom::exit_routine(\%modifier) and _exit => my::module::exit_routine(\%modifier), among other alternatives.

Hitachi::Raidcom::exit_routine(\%modifier) executes the subroutine and yields the value it returns.

&Hitachi::Raidcom::exit_routine(\%modifier) does the same. The & is optional in this case (with the arguments in parentheses) and makes no difference.

\&Hitachi::Raidcom::exit_routine(\%modifier) also runs the subroutine and yields a reference to the value it returns. That's why dumper gives you \''. The \ indicates a reference. In this case, a reference to the empty string.

What will probably work for you is (as AnomalousMonk suggested):

# Setup the log object my $log = LogSimple->new( logdir => $logdir, logfile => $logfile, logl +evel => $loglevel, verbosity => $verbosity, exit => sub { Hitachi::Ra +idcom::exit_routine(\%modifier) } );

With this initialization, $self->{_exit} should be set to a code reference: to the anonymous sub which does nothing but call Hitachi::Raidcom::exit_routine with the argument \%modifier and return whatever that sub returns. The sub isn't executed immediately. It is executed later, in sub wlog, when the code reference is de-referenced and called. But, I haven't tested...

While this will probably work for you, I will mention closure (just one of many articles on the subject). It is a confusing feature for many, so I suggest you not worry about it immediately, but once you have this working, learn about closure before making too much use of anonymous subroutines accessing lexical variables.


In reply to Re^4: Dereferencing %hash that does not exist. by ig
in thread Dereferencing %hash that does not exist. by perldarren

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (2)
As of 2024-04-20 05:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found