Sman::Man::Find - Find manpage files for indexing by sman-update


Sman documentation Contained in the Sman distribution.

Index


Code Index:

NAME

Top

Sman::Man::Find - Find manpage files for indexing by sman-update

SYNOPSIS

Top

  my @manfiles = Sman::Man::Find::FindManFiles();

DESCRIPTION

Top

Provides a single function, FindManFiles(), which looks for man-like files along the passed manpath, or the env var MANPATH, or the output of manpath, whichever is defined first. If none is defined, /usr/share/man is used as the manpath.

AUTHOR

Top

Josh Rabinowitz <joshr>

SEE ALSO

Top

sman-update, sman, sman.conf


Sman documentation Contained in the Sman distribution.

package Sman::Man::Find; 
#$Id: Find.pm,v 1.11 2005/09/02 21:29:26 joshr Exp $

use File::Find; 
use strict;
use warnings;

# to be called like "my @files = Sman::Man::Find::FindManFiles()" 
sub FindManFiles {  # get manfiles in MANPATH
	my ($manpath, $matchregex) = @_;
    my @files;
    chomp($manpath ||= $ENV{MANPATH} || `manpath` || '/usr/share/man');

	#$matchregex = 'man/man.*\.' unless defined $matchregex;

	my @dirs =  split(/:/, $manpath);
	for my $dir (@dirs) {
		next unless ($dir && -e $dir && (-d $dir || -l $dir));	# skip non-existent dirs
		File::Find::find( sub { 
		  my $n = $File::Find::name;
		  push @files, $n 
		  if -f $n && $n =~ m!man/man.*\.!
	   }, $dir ); 
	}
	return @files;
} 

1;