App-Timestamper-Format
view release on metacpan - search on metacpan
view release on metacpan or search on metacpan
lib/App/Timestamper/Format.pm view on Meta::CPAN
use App::Timestamper::Format::Filter::TS ();
sub new
{
my $class = shift;
my $self = bless {}, $class;
$self->_init(@_);
return $self;
}
sub _init
{
my ( $self, $args ) = @_;
my $argv = [ @{ $args->{argv} } ];
my $help = 0;
my $man = 0;
my $version = 0;
if (
!(
my $ret = GetOptionsFromArray(
$argv,
'help|h' => \$help,
man => \$man,
version => \$version,
)
)
)
{
die "GetOptions failed!";
}
if ($help)
{
pod2usage(1);
}
if ($man)
{
pod2usage( -verbose => 2 );
}
if ($version)
{
print "ts-format version $App::Timestamper::VERSION .\n";
exit(0);
}
$self->{_argv} = $argv;
}
sub run
{
my ($self) = @_;
local @ARGV = @{ $self->{_argv} };
STDOUT->autoflush(1);
App::Timestamper::Format::Filter::TS->new->fh_filter( \*ARGV,
sub { print $_[0]; } );
return;
}
1;
__END__
=pod
=encoding utf-8
=head1 NAME
App::Timestamper::Format - prefix lines with formatted timestamps of their arrivals.
=head1 VERSION
version 0.2.0
=head1 SYNOPSIS
use App::Timestamper::Format;
App::Timestamper::Format->new({ argv => [@ARGV] })->run();
=head1 DESCRIPTION
App::Timestamper::Format is a pure-Perl command line program that filters the input
so the formatted timestamps based on the C<TIMESTAMPER_FORMAT> environment variable are
prefixed to the lines based on the time of the arrival.
So if the input was something like:
First Line
Second Line
Third Line
It will become something like:
11:12:00\tFirst Line
11:12:02\tSecond Line
11:12:04\tThird Line
=head1 SUBROUTINES/METHODS
=head2 new
A constructor. Accepts the argv named arguments.
=head2 run
Runs the program.
=head1 SEE ALSO
view all matches for this distributionview release on metacpan - search on metacpan
( run in 1.661 second using v1.00-cache-2.02-grep-82fe00e-cpan-72ae3ad1e6da )