#!/usr/bin/perl use strict; use warnings; use constant { MAX => 1, SIGIL => 0 }; $| = 1; chomp( my $term_lines = 0+`tput lines` ); chomp( my $term_columns = 0+`tput cols` ); @ARGV % 2 == 0 or die "$0: SIGIL SCALE ...\n"; my @trackers = map [ @ARGV[$_*2, 1+($_*2) ] ], 0 .. $#ARGV / 2; my @lines; while (<STDIN>) { my @F = /(\d+)/g or next; push @lines, \ @F; shift @lines if @lines >= $term_lines; # Drop my colored dots onto the field. my @cols = (' ') x $term_columns; for my $ix ( 0 .. $#trackers ) { my $tracker = $trackers[$ix]; my $max = \ $tracker->[MAX]; my $sigil = $tracker->[SIGIL]; my $datum = $F[$ix]; if ( $$max < $datum ) { $$max = $datum; } my $scale = $$max; my $adjusted = $scale == 0 ? 0 : $datum / $scale; my $start_col = $#cols * $adjusted; for my $char ( 0 .. length($sigil)-1 ) { $cols[ $start_col + $char ] = "\e[" . (31 + $ix) . 'm' . sub +str( $sigil, $char, 1 ) . "\e[0m"; } # print "ix:$ix,col:$$col,max:$$max,sigil:$sigil,datum:$datum, +scale:$scale,adjusted:$adjusted,col_idx:$col_idx\n"; } splice @cols, $term_columns - 1 if @cols > $term_columns; print join( '', @cols ) . "\n"; }

In reply to Lookee - Streaming graph for a console by diotalevi

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.