Thought I ought to make this thread a little clearer - I thought my problem was gone but it seems that it's only just started:
From my script I can do these ok:
my $return = my::module::exit_routine(); sub reverse_modifier { # I modify default behaviour of the exit routine if I get passed - som +e times I am not needed. } my %modifier = ( reverse_modifier => \&reverse_modifier ); my $return = my::module::exit_routine(\%modifier);
In my::module::exit_routine I can deal with %modifier being present or not:
my %revmod = eval { %{ $_[0] } }
But here is my new sticking point - I am unable to find a way to do this from my script:
my $log = LogSimple->new(_exit => my::module::exit_routine(\%modifier) + ); $log->err("An error occured, _exit will happen before I exit but now I + want to force exit_routine to also use the \%modifier as well")
When an error is trapped and $log->err is executed I get:
Not a CODE reference at /usr/local/lib/.../LogSimple.pm line 122:
From my LogSimple package line 122 = $exit_ref->($self);


Effectively I am trying to send a reference which has another reference as one of it's parameters and my syntax is completely jiggered.
Infact, the whole concept could be busted up now that I am trying to introduce %modifier to plug up a hole I never knew I had.
Package LogSimple ... sub wlog { my ($self,$MESSAGE,$ERR,$LEVEL,$LOGLEVEL) = @_; my $TIME = datetime(); my $exit_ref; if ( $LOGLEVEL <= $self->{_loglevel} ) { open (LOG, ">>$self->{_log}") || warn "Unable to open log file + $self->{_log}: $!"; print LOG "$LEVEL: $TIME : $self->{_script} : $MESSAGE\n"; print "$LEVEL: $TIME : $self->{_script} : $MESSAGE\n" if ( $se +lf->{_verbosity} > 0 ); close (LOG); } if ( $ERR ) { if ( exists $self->{_exit} ) { use Data::Dumper; print Dumper $self->{_exit}; $exit_ref = $self->{_exit}; $exit_ref->($self); # LINE 122 if ( $LOGLEVEL <= $self->{_loglevel} ) { open (LOG, ">>$self->{_log}") || warn "Unable to open log file + $self->{_log}: $!"; print LOG "$LEVEL: $TIME : $self->{_script} : $MESSAGE\n"; print "$LEVEL: $TIME : $self->{_script} : $MESSAGE\n" if ( $se +lf->{_verbosity} > 0 ); close (LOG); }; } exit $ERR } }
Any assistance much appreciated.

Regards,
Darren 

In reply to Re: Dereferencing %hash that does not exist. by perldarren
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":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.