Talk:Sparkline in unicode: Difference between revisions

shorter, faster sparktest.pl
(Most of these are buggy)
(shorter, faster sparktest.pl)
Line 19:
This is some Perl code that will report the widths of same-height sections of output, when provided with a sparkline on standard input. Non-sparkline-lines are ignored. The line produced from a continuous integer sequence should produce eight equal widths (or almost equal if the sequence length is not a multiple of eight).
 
<code> perl -Mutf8CS -CSMutf8 -nenle 'chomp$,=" "; sy/[^▁-█]//g; next unless length; @c=split ""cd; $i=$li=$lc=0; forprint grep $i^=1, (0..@c)map { iflength, /($c[$i] ne $lc(.) { $w=$i-$li; print "$w "\2*)/g if $w;length' $li=$i } $lc=$c[$i]||"" };print "\n"'</code>
 
Sample usage (in bash, and assuming program accepts space-separated data on standard input):