in reply to Accessing a scalar value in another subroutine?
Why do you want to do this rather than just use POD? ("I heart Python" is not a good reason.)
That having been said, there's actually a really easy way to do this for object-oriented code (i.e. subs designed to be called as methods rather than functions).
use v5.14; package Foobar { sub new { bless [] => shift; } sub quux { return "documentation" unless @_; say "The method has been called!"; } } my $obj = Foobar->new; $obj->quux; # calls the method print Foobar::quux(); # prints the documentation
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Accessing a scalar value in another subroutine?
by LanX (Saint) on Sep 23, 2012 at 21:01 UTC | |
by Corion (Patriarch) on Sep 23, 2012 at 21:44 UTC | |
by LanX (Saint) on Sep 23, 2012 at 21:51 UTC | |
by Anonymous Monk on Sep 23, 2012 at 22:34 UTC |