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| ----------
In reply to Re: Visualisation of environment
by BrowserUk
in thread Visualisation of environment
by AndreasL
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |