Term::TtyRec::Plus is a Perl module to read a ttyrec.
SYNOPSIS
Term::TtyRec::Plus is a module that lets you read ttyrec files. The related module, Term::TtyRec is designed more for simple interactions. Term::TtyRec::Plus gives you more information and, using a callback, lets you munge the data block and timestamp. It will do all the subtle work of making sure timing is kept consistent, and of rebuilding each frame header.
use Term::TtyRec::Plus;
my $ttyrec = Term::TtyRec::Plus->new();
while ($frame_ref = $ttyrec->next_frame())
{
# do stuff with $frame_ref, e.g.
$total_time += $frame_ref->{diff};
}
CONSTRUCTOR AND STARTUP
new()
Creates and returns a new Term::TtyRec::Plus object.
my $ttyrec = Term::TtyRec::Plus->new();
Parameters
Here are the parameters that > recognizes.
infile
The input filename. A value of "-", which is the default, or undef, means STDIN.
filehandle
The input filehandle. By default this is undef; if you have already opened the ttyrec then you can pass its filehandle to the constructor. If both filehandle and infile are defined, filehandle is used.
time_threshold
The maximum difference between two frames, in seconds. If undef, which is the default, there is no enforced maximum. The second most common value would be 10, which some ttyrec utilities (such as timettyrec) use.
frame_filter
A callback, run for each frame before returning the frame to the user of Term::TtyRec::Plus. This callback receives three arguments: the frame text, the timestamp, and the timestamp of the previous frame. All three arguments are passed as scalar references. The previous frame's timestamp is undef for the first frame. The return value is not currently looked at. If you modify the timestamp, the module will make sure that change is noted and respected in further frame timestamps. Modifications to the previous frame's timestamp are currently ignored.
sub halve_frame_time_and_stumblify
{
my ($data_ref, $time_ref, $prev_ref) = @_;
$$time_ref = $$prev_ref + ($$time_ref - $$prev_ref) / 2
if defined $$prev_ref;
$$data_ref =~ s/Eidolos/Stumbly/g;
}
State
In addition to passing arguments, you can modify Term::TtyRec::Plus's initial state, if you want to. This could be useful if you are chaining multiple ttyrecs together; you could pass a different initial frame. Support for such chaining might be added in a future version.
frame
The initial frame number. Default 0.
prev_timestamp
The previous frame's timestamp. Default undef.
accum_diff
The accumulated difference of all frames seen so far; see the section on diffed_timestamp in next_frame()'s return value. Default 0.
relative_time
The time passed since the first frame. Default 0.
Requirements:
· Perl
Product's homepage
Requirements:
· Perl