App-Stopwatch

 view release on metacpan or  search on metacpan

bin/stopwatch  view on Meta::CPAN

        }
    }

    # unbuffer STDOUT
    $|++;

    my $seconds = 0;

    while ($true) {

        clear();
        print_seconds($seconds);
        if ($second2cmd{$seconds}) {
            `$second2cmd{$seconds} 2> /dev/null &`;
        }

        sleep 1;
        $seconds++;

    }

}
main() if not caller;

1;

__END__

=pod

=encoding UTF-8

=head1 NAME

stopwatch

=head1 VERSION

version 1.2.0

=head1 SYNOPSIS

stopwatch [options]

 Options:

      --run time cmd    Execute `cmd` at specified time
      --help            Show this message

=head2 Basic usage

Most simple usage is just to run `stopwatch` without any options. The script
will start counting seconds and it will output the passed time:

    04:12:54

To stop script use ctrl+c

=head2 Timer feature

You can use this script as a timer. The script can execute command at desired
time. Here is an example:

    stopwatch --run 10m "terminal-notifier -message '10 min passed'"

This command will start counting seconds but when in 10 minutes after start
it will execute the command.

The `--run` options must get 2 parameters. First one is the time ('10m', '5s')
and the second one is the command that should be run at that time. You can
specify several `--run` options at once.

=head2 Source code

Project url: L<https://github.com/bessarabov/App-Stopwatch>

=begin comment get_seconds_from_string

    get_seconds_from_string( '3s' ); # 3
    get_seconds_from_string( '20m' ); # 1200


=end comment

=head1 AUTHOR

Ivan Bessarabov <ivan@bessarabov.ru>

=head1 COPYRIGHT AND LICENSE

This software is copyright (c) 2014 by Ivan Bessarabov.

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

=cut



( run in 1.872 second using v1.01-cache-2.11-cpan-39bf76dae61 )