This gets a bit flaky at the lower limit, and this application screams for Perl6::Form--if your brave:). I still can't quite wrap my brain around spill fields.

#! perl -slw use strict; our $MAX ||= 10; $MAX *= 3; my @ca = qw (ma mb mc md me mf mg mh); # 8-node cluster my @cb = qw (mi mj mk ml mm mn mo mp); # 8-node cluster my @cc = qw (mq mr ms mt); # 4-node cluster my @cd = qw (mu mv mw mx); # 4-node cluster my @ce = qw (my mz); # 2-node cluster my @cf = qw (m1 m1); # 2-node cluster my @cg = qw (m3 m4); # 2-node cluster my @ch = qw (m5); # standalone my @ci = qw (m6); # standalone my @cj = qw (m7); # standalone my @ck = qw (m8); # standalone push my( @c ), \( @ca, @cb, @cc, @cd, @ce, @cf, @cg, @ch, @ci, @cj, @c +k ); my @lines = ( '|' ) x 3; for my $c ( @c ) { unless( @$c % 2 ) { $lines[ 0 ] .= join( ' ', @{ $c }[ 0 .. $#$c / 2 ] ) + . '|'; $lines[ 1 ] .= ' ' x ($#$c / 2 * 3 + 1 ) . '|'; $lines[ 2 ] .= join( ' ', @{ $c }[ $#$c / 2 +1 .. $#$c ] ) + . '|'; } else { if( length $lines[ 0 ] < length $lines[ 2 ] ) { $lines[ 0 ] .= "@$c|"; $lines[ 1 ] .= '--|'; } else{ $lines[ 2 ] .= "@$c|"; } } } #print for @lines; my $n = 0; while( length $lines[ $n ] > $MAX ) { my $p = rindex( $lines[ $n ], '|', $MAX ); my $l = length( $lines[ $n ] ) - $p; $lines[ $n + 4 ] = substr( $lines[ $n ], $p, $l, '' ); $lines[ $n + 5 ] = substr( $lines[ $n + 1 ], $p, $l, '' ); $lines[ $n + 6 ] = substr( $lines[ $n + 2 ], $p, $l, '' ); $lines[ $n + 3 ] = ('-') x length $lines[ $n ]; $n += 4; } $_ .= '|' for @lines[ 0 .. $#lines - 4 ]; print '-' x length $lines[ 0 ]; print for @lines; print '-' x length $lines[ -1 ]; __END__ P:\test>338456 -MAX=4 ------------- |ma mb mc md| | | |me mf mg mh| ------------| |mi mj mk ml| | | |mm mn mo mp| ------------| |mq mr|mu mv| | | | |ms mt|mw mx| ------------| |my|m1|m3|m6| | | | |--| |mz|m1|m4|m5| ------------ |m8| |--| |m7| ---- P:\test>338456 -MAX=6 ------------- |ma mb mc md| | | |me mf mg mh| ------------| |mi mj mk ml|mq mr| | | | |mm mn mo mp|ms mt| ------------------| |mu mv|my|m1|m3|m6| | | | | |--| |mw mx|mz|m1|m4|m5| ------------------ |m8| |--| |m7| ---- P:\test>338456 -MAX=10 ------------------------------- |ma mb mc md|mi mj mk ml|mq mr| | | | | |me mf mg mh|mm mn mo mp|ms mt| ------------------------------ |mu mv|my|m1|m3|m6|m8| | | | | |--|--| |mw mx|mz|m1|m4|m5|m7| ---------------------- P:\test>338456 -MAX=14 ------------------------------------------- |ma mb mc md|mi mj mk ml|mq mr|mu mv|my|m1| | | | | | | | |me mf mg mh|mm mn mo mp|ms mt|mw mx|mz|m1| ------------------------------------------ |m3|m6|m8| | |--|--| |m4|m5|m7| ----------

Examine what is said, not who speaks.
"Efficiency is intelligent laziness." -David Dunham
"Think for yourself!" - Abigail

In reply to Re: Visualisation of environment by BrowserUk
in thread Visualisation of environment by AndreasL

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.