#!/usr/bin/perl ########################################### # podprint # 2005, Mike Schilli ########################################### use strict; use warnings; use Getopt::Std; use Pod::Usage; use vars qw($CVSVERSION $GROFF_CMD $PRINT_CMD); use File::Spec::Functions; $GROFF_CMD = "/usr/bin/groff -Tps -mandoc"; $PRINT_CMD = "lpr"; $CVSVERSION = '$Revision: 1.1 $'; getopts("hv", \my %opts); $PRINT_CMD = $opts{p} if defined $opts{p}; pod2usage() if $opts{h}; if($opts{v}) { my ($version) = $CVSVERSION =~ /(\d\S+)/; print "$0 $version\n"; exit 0; } pod2usage("Wrong number of arguments") unless defined $ARGV[0]; my $path = module_find($ARGV[0]); die "Can't find $ARGV[0]" unless defined $path; my $cmd = "pod2man $path | $GROFF_CMD | $PRINT_CMD"; open PIPE, "$cmd |" or die "Cannot open $cmd"; my $data = join '', ; close PIPE or die "Cannot close $cmd"; ########################################### sub module_find { ########################################### my($module_name) = @_; my $subpath = catfile(split "::", $module_name) . ".pm"; foreach $path (@INC) { my $fullpath = catfile($path, $subpath); if(-e $fullpath) { return $fullpath; } } return undef; } __END__ =head1 NAME podprint - Prints a Perl module documentation page on a postscript printer =head1 DOWNLOAD _SRC_HERE_ =head1 SYNOPSIS podprint Module::Name =head1 OPTIONS =over 8 =item B<-p> Specify an alternative print program (default: C). =item B<-v> Show the current version. =item B<-h> Show a help page. =back =head1 DESCRIPTION C is a simple script that combines the C utility and the C formatter, to create a Postscript file from a perldoc page and sends it off to a printer spooler (default C). =head1 EXAMPLES $ podprint Log::Log4perl =head1 LEGALESE Copyright 2005 by Mike Schilli, all rights reserved. This program is free software, you can redistribute it and/or modify it under the same terms as Perl itself. =head1 AUTHOR 2005, Mike Schilli