NAME

IO::Pager::Perl - Pipe output to PAGER if destination is a TTY with Perl

SYNOPSIS

#Required if you want unbuffered output
use Term::ReadKey;

{
  #Configure extra shortcuts, add an embedded shell
  %IO::Pager::Perl::CFG = ( '!' => sub{ "REPL implementation" } );

  #Can be instantiated functionally or OO, same as other sub-classes.
  my $token = new IO::Pager::Perl;

  $token->print("Pure perl goodness...\n") while 1;
}

DESCRIPTION

IO::Pager::Perl is a simple, extensible, perl-based pager.

If you want behavior similar to IO::Pager::Buffer do not load Term::ReadKey, and output will be buffered between keypresses.

See IO::Pager for method details.

CONFIGURATION

%IO::Pager::Perl::CFG elements are passed to Term::Pager's add_func method. The hash keys are single key shortcut definitions, and values a callback to be invoked when said key is pressed e.g;

#Forego default left-right scrolling for more less-like seeking
%IO::Pager::Perl::CFG = (
  '<' => \&Term::Pager::to_top,   #not move_left
  '>' => \&Term::Pager::to_bottom #not move_right
);

Because IO::Pager::Perl forks, the callback functions must exist prior to instantiation of the IO::Pager object to work properly.

METHODS

All methods are inherited from IO::Pager; except for instantiation and print.

CAVEATS

You probably want to do something with SIGPIPE eg;

eval {
  local $SIG{PIPE} = sub { die };
  local $STDOUT = IO::Pager::open(*STDOUT);

  while (1) {
    # Do something
  }
}

# Do something else

SEE ALSO

IO::Pager, Term::Pager, IO::Pager::Buffered, IO::Pager::Page,

AUTHOR

Jerrad Pierce <jpierce@cpan.org>

Florent Angly <florent.angly@gmail.com>

This module was inspired by Monte Mitzelfelt's IO::Page 0.02

Significant proddage provided by Tye McQueen.

COPYRIGHT AND LICENSE

Copyright (C) 2003-2018 Jerrad Pierce

  • Thou shalt not claim ownership of unmodified materials.

  • Thou shalt not claim whole ownership of modified materials.

  • Thou shalt grant the indemnity of the provider of materials.

  • Thou shalt use and dispense freely without other restrictions.

Or, if you prefer:

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.0 or, at your option, any later version of Perl 5 you may have available.