aboutsummaryrefslogtreecommitdiffstats
path: root/unix/cat-lps.pl
blob: c83f037b1b5135872ca04e771a69f614ecd19aaf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/usr/bin/env perl
#
# Cat file to terminal at particular speed of lines per second
# https://superuser.com/a/526249
#
# Usage: cat-lps.pl [lps] [file]...
#

use warnings;
use strict;
use Time::HiRes qw|time|;

my $start=time;
my $lps=300;

$lps=shift @ARGV if @ARGV && $ARGV[0]=~/^(\d+)$/;
my $sleepPerLine=1/$lps;

print &&
    select undef,undef,undef,($start + $sleepPerLine*$. - Time::HiRes::time)
    while <>