From 88d85c80d025e0fd6b7c8fad155dc3a1cdc8b992 Mon Sep 17 00:00:00 2001 From: Aaron LI Date: Sat, 20 Jun 2020 19:13:12 +0800 Subject: Add unix/cat-lps.pl: Cat file at a given speed of line/sec Credit: https://superuser.com/a/526249 --- unix/cat-lps.pl | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100755 unix/cat-lps.pl (limited to 'unix') 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 <> -- cgit v1.2.2