Index: trunk/klask
===================================================================
--- trunk/klask	(revision 310)
+++ trunk/klask	(revision 311)
@@ -7,5 +7,5 @@
 use strict;
 use warnings;
-use version; our $VERSION = qv('0.7.3');
+use version; our $VERSION = qv('0.7.4');
 
 use Readonly;
@@ -21,7 +21,8 @@
 use List::Util 'shuffle';
 use Digest::SHA qw(sha512_base64);
+use Text::Table; # libtext-table-perl http://blogs.perl.org/users/steven_haryanto/2014/07/benchmarking-several-ascii-table-generator-modules.html
 
 # apt-get install snmp fping libnet-cidr-lite-perl libnet-netmask-perl libnet-snmp-perl libnetaddr-ip-perl libyaml-perl
-# libcrypt-des-perl libcrypt-hcesha-perl libdigest-hmac-perl
+# libcrypt-des-perl libcrypt-hcesha-perl libdigest-hmac-perl libtext-table-perl
 # arping net-tools fping bind9-host arpwatch
 
@@ -2847,5 +2848,4 @@
 #---------------------------------------------------------------
 sub cmd_exportsw_txt {
-
    my $switch_connection = YAML::Syck::LoadFile("$KLASK_SW_FILE");
 
@@ -2854,20 +2854,43 @@
    my %db_switch_connected_on_port = %{$switch_connection->{'connected_on_port'}};
 
-   print "Switch output port and parent port connection\n";
-   print "---------------------------------------------\n";
+   my $tb_child = Text::Table->new( # http://www.perlmonks.org/?node_id=988320
+      {align => 'left',   align_title => 'left',   title => 'Child_Switch'},
+      {align => 'right',  align_title => 'right',  title => 'Output_Port'},
+      {align => 'center', align_title => 'center', title => 'Link'},
+      {align => 'left',   align_title => 'left',   title => 'Input_Port'},
+      {align => 'left',   align_title => 'left',   title => 'Parent_Switch'},
+      );
+   #print "Switch output port and parent port connection\n";
+   #print "---------------------------------------------\n";
    for my $sw (sort keys %db_switch_output_port) {
-      my $arrow ='-->';
-         $arrow ='==>' if $db_switch_output_port{$sw} =~ m/^(Trk|Br|Po)/;
+      my $arrow ='--->';
+         $arrow ='===>' if $db_switch_output_port{$sw} =~ m/^(Trk|Br|Po)/;
       if (exists $db_switch_parent{$sw}) {
-         printf "%-28s %8s %3s %-8s %-25s\n", $sw, $db_switch_output_port{$sw}, $arrow, $db_switch_parent{$sw}->{'port_hr'}, $db_switch_parent{$sw}->{'switch'};
+         #printf "%-28s %8s %3s %-8s %-25s\n", $sw, $db_switch_output_port{$sw}, $arrow, $db_switch_parent{$sw}->{'port_hr'}, $db_switch_parent{$sw}->{'switch'};
+         $tb_child->add($sw, $db_switch_output_port{$sw}, $arrow, $db_switch_parent{$sw}->{'port_hr'}, $db_switch_parent{$sw}->{'switch'});
+
          }
       else {
-         printf "%-28s %8s %3s %-8s %-25s\n", $sw, $db_switch_output_port{$sw}, $arrow, '', 'router';
-         }
-      }
+         #printf "%-28s %8s %3s %-8s %-25s\n", $sw, $db_switch_output_port{$sw}, $arrow, '', 'router';
+         $tb_child->add($sw, $db_switch_output_port{$sw}, $arrow, '', 'router');
+         }
+      }
+   my @colrange = map { scalar $tb_child->colrange($_) } (0 .. 4); # force scaler context
+   $tb_child->add(map { ' ' x $_ } reverse @colrange); # add empty line to force symetric table
+   print $tb_child->title();
+   print $tb_child->rule('-');
+   print $tb_child->body(0, $tb_child->body_height()-1); # remove last fake line
+   $tb_child->clear;
+
    print "\n";
-
-   print "Switch parent and children port inter-connection\n";
-   print "------------------------------------------------\n";
+   my $tb_parent = Text::Table->new( # http://www.perlmonks.org/?node_id=988320
+      {align => 'left',   align_title => 'left',   title => 'Parent_Switch'},
+      {align => 'right',  align_title => 'right',  title => 'Input_Port'},
+      {align => 'center', align_title => 'center', title => 'Link'},
+      {align => 'left',   align_title => 'left',   title => 'Output_Port'},
+      {align => 'left',   align_title => 'left',   title => 'Child_Switch'},
+      );
+   #print "Switch parent and children port inter-connection\n";
+   #print "------------------------------------------------\n";
    for my $swport (sort keys %db_switch_connected_on_port) {
       my ($sw_connect, $port_connect) = split m/ $SEP_SWITCH_PORT /xms, $swport, 2;
@@ -2876,11 +2899,20 @@
             $arrow ='<==' if $port_connect =~ m/^(Trk|Br|Po)/;
          if (exists $db_switch_output_port{$sw}) {
-            printf "%-28s %8s %3s %-8s %-25s\n", $sw_connect, $port_connect, $arrow, $db_switch_output_port{$sw}, $sw;
+            #printf "%-28s %8s %3s %-8s %-25s\n", $sw_connect, $port_connect, $arrow, $db_switch_output_port{$sw}, $sw;
+            $tb_parent->add($sw_connect, $port_connect, $arrow, $db_switch_output_port{$sw}, $sw);
             }
          else {
-            printf "%-28s %8s %3s %-8s %-25s\n", $sw_connect, $port_connect, $arrow, '', $sw;
+            #printf "%-28s %8s %3s %-8s %-25s\n", $sw_connect, $port_connect, $arrow, '', $sw;
+            $tb_parent->add($sw_connect, $port_connect, $arrow, '', $sw);
             }
          }
       }
+   @colrange = map { scalar $tb_parent->colrange($_) } (0 .. 4); # force scaler context
+   $tb_parent->add(map { ' ' x $_ } reverse @colrange); # add empty line to force symetric table
+   print $tb_parent->title();
+   print $tb_parent->rule('-');
+   print $tb_parent->body(0, $tb_parent->body_height()-1); # remove last fake line
+   $tb_parent->clear;
+
    return;
    }
