diff options
| author | Aaron LI <aly@aaronly.me> | 2020-06-20 19:13:12 +0800 | 
|---|---|---|
| committer | Aaron LI <aly@aaronly.me> | 2020-06-20 19:13:12 +0800 | 
| commit | 88d85c80d025e0fd6b7c8fad155dc3a1cdc8b992 (patch) | |
| tree | 3be13287a2c0952f25a9506d9554ef127197bf43 /unix | |
| parent | 70a7ec1719bf5ee9cedac46412fb4f7dbb9de926 (diff) | |
| download | atoolbox-master.tar.bz2 | |
Credit: https://superuser.com/a/526249
Diffstat (limited to 'unix')
| -rwxr-xr-x | unix/cat-lps.pl | 21 | 
1 files changed, 21 insertions, 0 deletions
| diff --git a/unix/cat-lps.pl b/unix/cat-lps.pl new file mode 100755 index 0000000..c83f037 --- /dev/null +++ b/unix/cat-lps.pl @@ -0,0 +1,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 <> | 
