neilwatson has asked for the wisdom of the Perl Monks concerning the following question:
Greetings,
I'm attempting to learn brian_d_foy's modulino. In this early prototype I'm getting an uninitialized error about $VERSION. What is the cause?
#!/usr/bin/perl use strict; use warnings; use feature qw/say/; use vars qw/$VERSION/; $VERSION = 0.01; 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 the appli +cation else { undef } # everything else }; __PACKAGE__->$method(@ARGV) if defined $method; } sub run { say $VERSION; } $ ./foo.pl Use of uninitialized value $VERSION in say at ./foo.pl line 36.
Neil Watson
watson-wilson.ca
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: modulino and $VERSION
by AppleFritter (Vicar) on Jul 10, 2014 at 17:53 UTC | |
Re: modulino and $VERSION (all code in module , script as module )
by Anonymous Monk on Jul 11, 2014 at 03:30 UTC |