<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">package Pod::Perldoc::BaseTo;
use strict;
use warnings;

use vars qw($VERSION);
$VERSION = '3.28';

use Carp                  qw(croak carp);
use Config                qw(%Config);
use File::Spec::Functions qw(catfile);

sub is_pageable        { '' }
sub write_with_binmode {  1 }

sub output_extension   { 'txt' }  # override in subclass!

# sub new { my $self = shift; ...  }
# sub parse_from_file( my($class, $in, $out) = ...; ... }

#sub new { return bless {}, ref($_[0]) || $_[0] }

# this is also in Perldoc.pm, but why look there when you're a
# subclass of this?
sub TRUE  () {1}
sub FALSE () {return}

BEGIN {
 *is_vms     = $^O eq 'VMS'      ? \&amp;TRUE : \&amp;FALSE unless defined &amp;is_vms;
 *is_mswin32 = $^O eq 'MSWin32'  ? \&amp;TRUE : \&amp;FALSE unless defined &amp;is_mswin32;
 *is_dos     = $^O eq 'dos'      ? \&amp;TRUE : \&amp;FALSE unless defined &amp;is_dos;
 *is_os2     = $^O eq 'os2'      ? \&amp;TRUE : \&amp;FALSE unless defined &amp;is_os2;
 *is_cygwin  = $^O eq 'cygwin'   ? \&amp;TRUE : \&amp;FALSE unless defined &amp;is_cygwin;
 *is_linux   = $^O eq 'linux'    ? \&amp;TRUE : \&amp;FALSE unless defined &amp;is_linux;
 *is_hpux    = $^O =~ m/hpux/    ? \&amp;TRUE : \&amp;FALSE unless defined &amp;is_hpux;
 *is_openbsd = $^O =~ m/openbsd/ ? \&amp;TRUE : \&amp;FALSE unless defined &amp;is_openbsd;
 *is_freebsd = $^O =~ m/freebsd/ ? \&amp;TRUE : \&amp;FALSE unless defined &amp;is_freebsd;
 *is_bitrig = $^O =~ m/bitrig/ ? \&amp;TRUE : \&amp;FALSE unless defined &amp;is_bitrig;
}

sub _perldoc_elem {
  my($self, $name) = splice @_,0,2;
  if(@_) {
    $self-&gt;{$name} = $_[0];
  } else {
    $self-&gt;{$name};
  }
}

sub debugging {
	my( $self, @messages ) = @_;

    ( defined(&amp;Pod::Perldoc::DEBUG) and &amp;Pod::Perldoc::DEBUG() )
	}

sub debug {
	my( $self, @messages ) = @_;
	return unless $self-&gt;debugging;
	print STDERR map { "DEBUG $_" } @messages;
	}

sub warn {
	my( $self, @messages ) = @_;
	carp join "\n", @messages, '';
	}

sub die {
	my( $self, @messages ) = @_;
	croak join "\n", @messages, '';
	}

sub _get_path_components {
	my( $self ) = @_;

	my @paths = split /\Q$Config{path_sep}/, $ENV{PATH};

	return @paths;
	}

sub _find_executable_in_path {
	my( $self, $program ) = @_;

	my @found = ();
	foreach my $dir ( $self-&gt;_get_path_components ) {
		my $binary = catfile( $dir, $program );
		$self-&gt;debug( "Looking for $binary\n" );
		next unless -e $binary;
		unless( -x $binary ) {
			$self-&gt;warn( "Found $binary but it's not executable. Skipping.\n" );
			next;
			}
		$self-&gt;debug( "Found $binary\n" );
		push @found, $binary;
		}

	return @found;
	}

1;

__END__

=head1 NAME

Pod::Perldoc::BaseTo - Base for Pod::Perldoc formatters

=head1 SYNOPSIS

    package Pod::Perldoc::ToMyFormat;

    use parent qw( Pod::Perldoc::BaseTo );
    ...

=head1 DESCRIPTION

This package is meant as a base of Pod::Perldoc formatters,
like L&lt;Pod::Perldoc::ToText&gt;, L&lt;Pod::Perldoc::ToMan&gt;, etc.

It provides default implementations for the methods

    is_pageable
    write_with_binmode
    output_extension
    _perldoc_elem

The concrete formatter must implement

    new
    parse_from_file

=head1 SEE ALSO

L&lt;perldoc&gt;

=head1 COPYRIGHT AND DISCLAIMERS

Copyright (c) 2002-2007 Sean M. Burke.

This library is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.

This program is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of
merchantability or fitness for a particular purpose.

=head1 AUTHOR

Current maintainer: Mark Allen C&lt;&lt; &lt;mallen@cpan.org&gt; &gt;&gt;

Past contributions from:
brian d foy C&lt;&lt; &lt;bdfoy@cpan.org&gt; &gt;&gt;
Adriano R. Ferreira C&lt;&lt; &lt;ferreira@cpan.org&gt; &gt;&gt;,
Sean M. Burke C&lt;&lt; &lt;sburke@cpan.org&gt; &gt;&gt;

=cut
</pre></body></html>