in reply to Automatic documentation stubs for .pl source

Just for kicks here's my attempt at handling fully qualified names (including archaic forms), prototypes, and attributes.

#! perl -slw use strict; use re 'eval'; my $re_sub = qr[ sub\s+ ( (?: (\w+)? (?: :: | ' ) )* \w+ \s* ) (?{ $name = $^N }) ( (?: \( [&$@\\; ]+ \) )? \s* ) (?{ $prototype = $^N || '' }) ( (?: : \s* \w+ (?: \( .+? \) )? \s* )* ) (?{ $attributes = $^N || '' }) \{ ]x; BEGIN{ @ARGV = map{ glob } @ARGV if $^O eq 'MSWin32'; } our( $name, $prototype, $attributes ); local $/ = undef; while( <> ) { tr[\n][]; s[\s+][ ]g; printf "%-40s : Name: %-20s\tPrototype: %10s\n\tAttributes : %s\n" +, $ARGV, $name, $prototype, $attributes while m[$re_sub]g; }

It's quite interesting to run this against the files in your libpath.

Of course this doesn't respect comments or pod boundaries.


Examine what is said, not who speaks.
"Efficiency is intelligent laziness." -David Dunham
"When I'm working on a problem, I never think about beauty. I think only how to solve the problem. But when I have finished, if the solution is not beautiful, I know it is wrong." -Richard Buckminster Fuller
If I understand your problem, I can solve it! Of course, the same can be said for you.