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

Re: [MacPerl] Shuck @INC



At 13.08 -0400 1998.09.16, Amitai Schlair wrote:
>I dig Shuck's "Lookup..." feature, but it doesn't look in site_perl
>(which is defined in MacPerl, as distributed). Why not, and how can I
>fix it?

Well, Shuck uses the MacPerl Help file, which is a DB_File file that
contains paths.  So you can rewrite that file each time you install a new
module, doc, etc.  Or, you can use this script I wrote called macperldoc.
Its one drawback is that it actually compiles what it is looking for if it
is a .pm file (see the eval("require $why") section), but that should not
be a big problem, methinks.  Just be aware of it.

I put it in my "MacPerl Scripts" folder and call it "perldoc/2" so I can
access it from the MacPerl app with cmd-2.

#!perl
# macperldoc a.k.a. perldoc/2
# requires IC setup to use Shuck for pod URLs
use strict;
my($what, $why, $where, $ic, %help);

$what = MacPerl::Ask('What do YOU want?') or exit;
($why = $what) =~ s|::|/|g; $why .= '.pm';
eval("require '$why'");

if (!$@) {
  $where = $INC{$why};
} elsif (-e "$ENV{MACPERL}pod:$what.pod") {
  $where = "$ENV{MACPERL}pod:$what.pod";
} else {
  require DB_File;
  require Fcntl;
  tie(%help, 'DB_File', "$ENV{MACPERL}MacPerl Help",
    Fcntl::O_RDONLY(), 0) or die $!;
  if (defined($help{$what})) {
    ($where = $help{$what}) =~ s|^pod:|$ENV{MACPERL}|;
    $where =~ tr|/|:|;
  }
}

if (!$where) {
  MacPerl::Answer("Cannot find $what.");
  exit;
} else {
  require Mac::InternetConfig;
  Mac::InternetConfig->import();
  $ic = ICStart();
  ICGeneralFindConfigFile($ic);
  ICLaunchURL($ic, 0, "pod:///$where");
  ICStop($ic);
}
__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 mac-perl-request@iis.ee.ethz.ch