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

Re: [MacPerl] perldoc on Mac



OK, one last one.  It didn't like some bareword eval'd strings, and didn't
quit gracefully on some cancels.  Also speed up initial execution with
delayed require instead of use.

#!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