package DocString; use Attribute::Handlers; use Data::Dumper; no warnings 'redefine'; our $docstrings; # sub Doc :ATTR(CODE) { sub UNIVERSAL::Doc :ATTR(CODE) { my ($package, $symbol, $referent, $attr, $data, $phase, $filename, $linenum) = @_; $docstrings->{ $package }{ *{$symbol}{NAME} } = "@$data"; } # you could also have a docstring function exported from this module that, given a package # and a sub returns # $DocString::docstrings->{$pkg}{$sub}); 1;