[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[MacPerl] fill macperl help with new modules



I got tired of not having my MacPerl modules and docs installed into pod
and site_perl in my MacPerl Help file for use by Shuck.  So I wrote this.
It copies your old MacPerl Help file to the Docs directory (creating it if
necessary), then runs through lib, pod, and site_perl is succession.  You
might not like the ordering I use, or you might have other folders to add,
so adjust it to suit your needs.

#!perl -w
# fill_macperl_help.plx
# pudge@pobox.com, Friday, March 5, 1999
use DB_File;
use File::Copy;
use File::Find;
use strict;
use vars qw($MPD $CWD %DATA %MPH);

$MPD = $ENV{MACPERL};

my $file = "${MPD}MacPerl Help"; # data stored in Help file, a DBM
my $oldf = "${MPD}Docs:MacPerl Help.old";

unless (-e "${MPD}Docs:") {
    mkdir("${MPD}Docs:", 0755) or die $!;
}

unless (-e $oldf) {               # copy if copy does not exist
  copy($file, $oldf) or die $!;
}

tie(my %MPH, 'DB_File', "${MPD}MacPerl Help", O_RDWR, 0644) or die $!;

for $CWD ("${MPD}lib:", "${MPD}pod:", "${MPD}site_perl:") {
    local %DATA;
    find(\&get_pods, $CWD);
    set_pods();
}

# fix pod menu items to have name of file in menu item
# comment out if you don't want it
$MPH{' MENU'} =~
    s|^(.*)\t(.*/((?:mac)?perl[^/]*)\.pod)$|$1 ($3)\t$2|mg;

untie(%MPH);
MacPerl::Quit(2); # quit MacPerl app, important ... quit Shuck manually, too



sub get_pods {
    return unless /\.p(od|m)$/;
    my($dir, $name) = ($File::Find::dir, $File::Find::name);

    (my $pod = $name) =~ s/^$CWD//;  # get name of file
    $pod =~ s/:/::/g;                # (relative to $CWD)
    (my $new = $name) =~ s/^$MPD//;  # get path to file
    $new =~ tr|:|/|;                 # (relative to $MPD)
    $DATA{$pod} = $new;              # save name in temp hash
}

sub set_pods {
    # this is in a separate directory to make sure
    # that pod overrides pm.
    for my $pod (sort keys %DATA) {
        (my $new = $DATA{$pod}) =~ tr|:|/|;
        $pod =~ s/\.p(od|m)$//;
        $MPH{$pod} = "pod:$new";
    }
}

__END__


--
Chris Nandor          mailto:pudge@pobox.com         http://pudge.net/
%PGPKey = ('B76E72AD', [1024, '0824090B CE73CA10  1FF77F13 8180B6B6'])

===== Want to unsubscribe from this list?
===== Send mail with body "unsubscribe" to macperl-request@macperl.org