Skip to content

Instantly share code, notes, and snippets.

@gonter
Created September 13, 2012 16:04
Show Gist options
  • Save gonter/3715363 to your computer and use it in GitHub Desktop.
Save gonter/3715363 to your computer and use it in GitHub Desktop.
convert list of perl package declarations into wiki table
#!/usr/bin/perl
#
# convert list of perl package declarations into wiki table
# the input should be the result of a something like
# fgrep -n 'package' <my-large-list-of-perl-scripts-and-modules>
#
use strict;
print "| *package_name* | *usage* | *file_name* |\n";
while (<>)
{
chop;
my ($fnm, $lnr, $pkg)= split (':', $_, 3);
my ($pkg_name, $pkg_name_wiki);
$pkg_name_wiki= $pkg_name= $1 if ($pkg =~ m#package\s+(\S+)\s*;#);
next unless (defined ($pkg_name));
$pkg_name_wiki=~ s/:/_/g;
$fnm=~ s#^\.\/##;
printf "| [[package $pkg_name_wiki|$pkg_name]] | | source:/trunk/$fnm\@L$lnr |\n";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment