# -*- perl -*- # # $Id: FindPods.pm,v 5.11 2008/02/03 16:10:51 eserte Exp $ # Author: Slaven Rezic # # Copyright (C) 2001,2003,2004,2005,2007 Slaven Rezic. All rights reserved. # This package is free software; you can redistribute it and/or modify # it under the same terms as Perl itself. # # Mail: slaven@rezic.de # WWW: http://www.rezic.de/eserte/ # package Tk::Pod::FindPods; =encoding iso-8859-2 =head1 NAME Tk::Pod::FindPods - find Pods installed on the current system =head1 SYNOPSIS use Tk::Pod::FindPods; my $o = Tk::Pod::FindPods->new; $pods = $o->pod_find(-categorized => 1, -usecache => 1); =head1 DESCRIPTION =cut use base 'Exporter'; use strict; use vars qw($VERSION @EXPORT_OK $init_done %arch $arch_re); @EXPORT_OK = qw/%pods $has_cache pod_find/; $VERSION = sprintf("%d.%02d", q$Revision: 5.11 $ =~ /(\d+)\.(\d+)/); BEGIN { # Make a DEBUG constant very first thing... if(defined &DEBUG) { } elsif(($ENV{'TKPODDEBUG'} || '') =~ m/^(\d+)/) { # untaint my $debug = $1; *DEBUG = sub () { $debug }; } else { *DEBUG = sub () {0}; } } use File::Find; use File::Spec; use File::Basename; use Config; sub new { my($class) = @_; my $self = bless {}, $class; $self->init; $self; } sub init { return if $init_done; %arch = guess_architectures(); $arch_re = "(" . join("|", map { quotemeta $_ } ("mach", keys %arch)) . ")"; $init_done++; } =head2 pod_find The B method scans the current system for available Pod documentation. The keys of the returned hash reference are the names of the modules or Pods (C<::> substituted by C --- this makes it easier for Tk::Pod::Tree, as the separator may only be of one character). The values are the corresponding filenames. If C<-categorized> is specified, then the returned hash has an extra level with four categories: B (for core language documentation), B (for pragma documentation like L or L), B (core or CPAN modules), and B