App-Timestamper-WithElapsed

 view release on metacpan or  search on metacpan

lib/App/Timestamper/WithElapsed.pm  view on Meta::CPAN

    my $out_fh;
    if ( defined( my $output_fn = $self->_output_fn ) )
    {
        open $out_fh, ">:encoding(utf-8)", $output_fn;
        $out_fh->autoflush(1);
    }

    my $last_line_time = time();
    my $init_time      = $self->_from_start ? ( $last_line_time + 0 ) : 0;
    STDOUT->autoflush(1);
    my $timer = IO::Async::Timer::Periodic->new(
        interval => 0.1,

        on_tick => scalar(
            $self->_absolute()
            ? sub {
                my $t = time();
                printf "\r%.8f since start", $t - $init_time;

                return;
                }

lib/App/Timestamper/WithElapsed.pm  view on Meta::CPAN

                {
                    close $out_fh;
                }
            }

            return 0;
        }
    );

    $loop->add($stream);
    $timer->start();
    $loop->add($timer);
    $loop->run();

    return;
}

1;

__END__

=pod



( run in 0.561 second using v1.01-cache-2.11-cpan-49f99fa48dc )