Sub::Defer - Online Linux Manual PageSection : 3pm
Updated : 2019-10-13
Source : perl v5.30.0
Note : User Contributed Perl Documentation
NAMESub::Defer − Defer generation of subroutines until they are first called
SYNOPSIS use Sub::Defer;
my $deferred = defer_sub 'Logger::time_since_first_log' => sub {
my $t = time;
sub { time − $t };
};
Logger−>time_since_first_log; # returns 0 and replaces itself
Logger−>time_since_first_log; # returns time − $t
DESCRIPTIONThese subroutines provide the user with a convenient way to defer creation of subroutines and methods until they are first called.
SUBROUTINES
defer_sub my $coderef = defer_sub $name => sub { ... }, \%options;
This subroutine returns a coderef that encapsulates the provided sub − when it is first called, the provided sub is called and is −itself− expected to return a subroutine which will be goto'ed to on subsequent calls. If a name is provided, this also installs the sub as that name − and when the subroutine is undeferred will re-install the final version for speed. Exported by default. Options A hashref of options can optionally be specified. package The package to generate the sub in. Will be overridden by a fully qualified $name option. If not specified, will default to the caller's package. attributes The ‟Subroutine Attributes” in perlsub to apply to the sub generated. Should be specified as an array reference.
undefer_sub my $coderef = undefer_sub \&Foo::name;
If the passed coderef has been deferred this will ‟undefer” it. If the passed coderef has not been deferred, this will just return it. If this is confusing, take a look at the example in the ‟SYNOPSIS”. Exported by default.
defer_info my $data = defer_info $sub;
my ($name, $generator, $options, $undeferred_sub) = @$data;
Returns original arguments to defer_sub, plus the undeferred version if this sub has already been undeferred. Note that $sub can be either the original deferred version or the undeferred version for convenience. Not exported by default.
undefer_all undefer_all();
This will undefer all deferred subs in one go. This can be very useful in a forking environment where child processes would each have to undefer the same subs. By calling this just before you start forking children you can undefer all currently deferred subs in the parent so that the children do not have to do it. Note this may bake the behavior of some subs that were intended to calculate their behavior later, so it shouldn't be used midway through a module load or class definition. Exported by default.
undefer_package undefer_package($package);
This undefers all deferred subs in a package. Not exported by default.
SUPPORTSee Sub::Quote for support and contact information.
AUTHORSSee Sub::Quote for authors.
COPYRIGHT AND LICENSESee Sub::Quote for the copyright and license. 0
Johanes Gumabo
Data Size : 10,089 byte
man-Sub::Defer.3pmBuild : 2024-12-05, 20:55 :
Visitor Screen : x
Visitor Counter ( page / site ) : 3 / 187,867
Visitor ID : :
Visitor IP : 18.119.135.67 :
Visitor Provider : AMAZON-02 :
Provider Position ( lat x lon ) : 39.962500 x -83.006100 : x
Provider Accuracy Radius ( km ) : 1000 :
Provider City : Columbus :
Provider Province : Ohio , : ,
Provider Country : United States :
Provider Continent : North America :
Visitor Recorder : Version :
Visitor Recorder : Library :
Online Linux Manual Page : Version : Online Linux Manual Page - Fedora.40 - march=x86-64 - mtune=generic - 24.12.05
Online Linux Manual Page : Library : lib_c - 24.10.03 - march=x86-64 - mtune=generic - Fedora.40
Online Linux Manual Page : Library : lib_m - 24.10.03 - march=x86-64 - mtune=generic - Fedora.40
Data Base : Version : Online Linux Manual Page Database - 24.04.13 - march=x86-64 - mtune=generic - fedora-38
Data Base : Library : lib_c - 23.02.07 - march=x86-64 - mtune=generic - fedora.36
Very long time ago, I have the best tutor, Wenzel Svojanovsky . If someone knows the email address of Wenzel Svojanovsky , please send an email to johanes_gumabo@yahoo.co.id .
If error, please print screen and send to johanes_gumabo@yahoo.co.id
Under development. Support me via PayPal.
ERROR : Need New Coding : (parse_manual_page_|249|Sub::Defer.3pm|36/37|el══─{─══.|.el══─{─══. ds -- \|\(em\|
) (htmlprn|149|Sub::Defer.3pm|36/37|.el══─{─══. ds -- — |.el══─{─══. ds -- \|\(em\|
) (parse_manual_page_|249|Sub::Defer.3pm|43|br══─}─══|'br══─}─══
) (htmlprn|149|Sub::Defer.3pm|43|'br══─}─══ |'br══─}─══
)