From: Mischa POSLAWSKY Date: Sun, 9 Feb 2020 15:58:24 +0000 (+0100) Subject: code cleanup with explicit readline loop X-Git-Url: http://git.shiar.nl/minime.git/commitdiff_plain/13b01312659f88bc4de22d31fd0f6920608cf347 code cleanup with explicit readline loop --- diff --git a/termimg b/termimg index 2545c9b..6599b3b 100755 --- a/termimg +++ b/termimg @@ -1,10 +1,12 @@ #!/bin/sh convert -compress none -resize 66x23 - pgm:- | -perl -nE ' -$_ eq "P2\n" or die "ascii pgm input required\n" if $. == 1; -next if $. <= 3; +perl -e ' +<> eq "P2\n" or die "ascii pgm input required\n"; +<>; <>; # ignore depth, dimensions -state @ch = split //, " .oO@"; -print $ch[ $_ / 256 * @ch ] for /\d+/g; -print $/; +my @ch = split //, " .oO@"; +while (<>) { + print $ch[ $_ * @ch >> 8 ] for /\d+/g; + print $/; +} '