in reply to Re: Is possible to force the execution of a END block at runtime, without need to start global destruction?
in thread Is possible to force the execution of a END block at runtime, without need to start global destruction?

Just to end the node, here's a XS function that I made that return a reference to the CODE of the END blocks:
void get_end_sub( pkg ) char * pkg PREINIT: CV *cv_end ; PPCODE: if ( PL_endav ) { long i ; SV **svp = av_fetch(PL_endav , 0 , FALSE) ; long lng = av_len( PL_endav ) ; EXTEND(SP, lng + 1 ) ; for( i = 0 ; i <= lng ; ++i ) { cv_end = (CV *) svp[i] ; if ( !strcmp( HvNAME(CvSTASH(cv_end)) , pkg) ) { PUSHs( newRV_inc( cv_end ) ); } } }
And you can use in this way:
my @end_subs = get_end_sub( 'Package::Foo' ) ; my $sub = $end_subs[0] ; &$sub() ;

Graciliano M. P.
"Creativity is the expression of the liberty".

  • Comment on Re: Re: Is possible to force the execution of a END block at runtime, without need to start global destruction?
  • Select or Download Code