Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

Re^3: Accessing a scalar value in another subroutine?

by Corion (Pope)
on Sep 23, 2012 at 21:44 UTC ( #995259=note: print w/replies, xml ) Need Help??

in reply to Re^2: Accessing a scalar value in another subroutine?
in thread Accessing a scalar value in another subroutine?

If you are hell-bent on doing that, and having doc-strings for your functions, the following style may be to your taste:

use vars %documentation; sub doc($$) { my ($for,$doc) = @_; $documentation{ $for } = $doc; }; doc('mysub1',<<'=cut'); =head2 C<< mysub1 >> This documents mysub1. An example: mysub1(); =cut sub mysub1 { ... }; doc('frobnicate',<<'=cut'); =head2 C<< frobnicate >> This documents frobnicate. An example: frobnicate(); =cut sub frobnicate { ... };

You will note from history that this style never caught on.

If you adhere to a strict documentation style, you may simply parse the POD and extract the function definitions from that. Using "docstrings" and parsing the module documentation are equivalent in that sense.

Replies are listed 'Best First'.
Re^4: Accessing a scalar value in another subroutine?
by LanX (Chancellor) on Sep 23, 2012 at 21:51 UTC
    well far from being DRY... :)

    Cheers Rolf

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://995259]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (7)
As of 2016-10-21 21:42 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (291 votes). Check out past polls.