Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

modulino and perldoc

by neilwatson (Priest)
on Jul 10, 2014 at 19:43 UTC ( [id://1093114]=perlquestion: print w/replies, xml ) Need Help??

neilwatson has asked for the wisdom of the Perl Monks concerning the following question:

Greetings again,

Regarding Modulino::Demo, specifically the following sections. How does the doc sub work? Is it supposed to run when the module is called using perldoc? I did try it, but I didn't see the s/__PACKAGE__/$package/; happen. Have I got it all wrong?

UNITCHECK { sub _running_under_docreader { # << !! $ENV{PERLDOC} } sub _running_under_tester { !! $ENV{HARNESS_ACTIVE} } sub _running_as_app { defined scalar caller } my $method = do { if( _running_under_docreader() ) { 'doc' } # reading docs # << elsif( _running_under_tester() ) { 'test' } # testing elsif( _running_as_app() ) { 'run' } # running else { undef } # everything else }; sub doc { say "Running as docs"; my $data = do { local( @ARGV, $/ ) = __FILE__; <>; }; my $package = __PACKAGE__; $data =~ s/__PACKAGE__/$package/; # AND << say $data; }

Neil Watson

Replies are listed 'Best First'.
Re: modulino and perldoc (perldoc -MModulino::Demo2 Modulino::Demo2 background)
by Anonymous Monk on Jul 11, 2014 at 06:46 UTC

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1093114]
Approved by boftx
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (6)
As of 2024-07-16 11:48 GMT
Find Nodes?
    Voting Booth?

    No recent polls found

    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.