Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??
    0: #!/usr/bin/perl
    1: use strict;
    2: use warnings;
    3: 
    4: print graph( @{[1..96]} );
    5: 
    6: #######################################################################
    7: ### give me an array of 96 integers that represent each of the
    8: ### 15-minute intervals in 24 hours.  I'll give you an ascii graph
    9: ### (of, e.g., concurrent users?)
    10: sub graph {
    11:   my( $i, $magic, $m, $p, $top, @g ) = ( 0, 20, 7, 96, 0, () );
    12:   for (0..$p-1) { $top = $top > $_[$_] ? $top : $_[$_] }
    13:   my $s = $top > $magic ? ( $top / $magic ) : 1;  ### calculate scale
    14:   for (0..$magic) {
    15:     $g[$_] = sprintf("%".($m-1)."d ",$_*$s) . ($_%5==0?'_':'.') x $p;
    16:     for $i (0..$p-1) { substr($g[$_],$i+$m,1) = '|' if $_[$i]/$s>$_ } }
    17:   join( "\n", reverse( @g ), ' Time: ' . '|^^^' x ( $p / 4 ),
    18:     ' ' x $m . "12am 1am 2am 3am 4am 5am 6am 7am 8am 9a 10a 11a " .
    19:     "12pm 1pm 2pm 3pm 4pm 5pm 6pm 7pm 8pm 9p 10p 11pm" );
    20: }  # end sub graph
    21: 
    22: __END__
    23:     96 ________________________________________________________________________________________________
    24:     91 ...........................................................................................|||||
    25:     86 ......................................................................................||||||||||
    26:     81 .................................................................................|||||||||||||||
    27:     76 ............................................................................||||||||||||||||||||
    28:     72 ________________________________________________________________________||||||||||||||||||||||||
    29:     67 ...................................................................|||||||||||||||||||||||||||||
    30:     62 ..............................................................||||||||||||||||||||||||||||||||||
    31:     57 .........................................................|||||||||||||||||||||||||||||||||||||||
    32:     52 ....................................................||||||||||||||||||||||||||||||||||||||||||||
    33:     48 ________________________________________________||||||||||||||||||||||||||||||||||||||||||||||||
    34:     43 ...........................................|||||||||||||||||||||||||||||||||||||||||||||||||||||
    35:     38 ......................................||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
    36:     33 .................................|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
    37:     28 ............................||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
    38:     24 ________________________||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
    39:     19 ...................|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
    40:     14 ..............||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
    41:      9 .........|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
    42:      4 ....||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
    43:      0 ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
    44:  Time: |^^^|^^^|^^^|^^^|^^^|^^^|^^^|^^^|^^^|^^^|^^^|^^^|^^^|^^^|^^^|^^^|^^^|^^^|^^^|^^^|^^^|^^^|^^^|^^^
    45:        12am 1am 2am 3am 4am 5am 6am 7am 8am 9a 10a 11a 12pm 1pm 2pm 3pm 4pm 5pm 6pm 7pm 8pm 9p 10p 11pm
    46: 
    

In reply to ascii graph by Anonymous Monk

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!
  • 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, 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, 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.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others meditating upon the Monastery: (5)
    As of 2015-08-01 00:20 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









      Results (285 votes), past polls