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
watson-wilson.ca
In reply to modulino and perldoc by neilwatson
For: | Use: | ||
& | & | ||
< | < | ||
> | > | ||
[ | [ | ||
] | ] |