Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2017
456
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 1.25 KB | None | 0 0
  1. sub BuildAndPrintTable
  2. {
  3.     my $tbl = Text::ASCIITable->new( { headingText => "SOGo Configuration" } );
  4.    
  5.     $tbl->setCols('SOGo Variable', 'Your Provided Value');
  6.     $tbl->setColWidth('SOGo Variable', 40, 1);
  7.     $tbl->alignCol('Your Provided Value', 'left');
  8.    
  9.     # go over the hash from the configuration file and start
  10.     # building our table
  11.     foreach my $k ( keys %$sogo)
  12.     {
  13.         if(ref $sogo->{$k} eq 'HASH')
  14.         {
  15.             # We've likely encountered the SOGoUserSources dictionary
  16.             # here, so we need to process this a bit differently.
  17.             my $sources = $sogo->{$k};
  18.            
  19.             $tbl->addRowLine(); # this clears a bit of space for us
  20.            
  21.             foreach my $k ( keys %$sources )
  22.             {
  23.                 $tbl->addRow($k, $sources->{$k});
  24.             }
  25.            
  26.             $tbl->addRowLine();
  27.         }
  28.         else
  29.         {
  30.             $tbl->addRow($k, $sogo->{$k});
  31.         }
  32.     }
  33.    
  34.     print $tbl;
  35. }
  36.  
  37. Results:
  38.  
  39.  
  40. +------------------------------------------+------------------------------------------------------------+
  41. | GroupSupport                             | HASH(0x8411978)                                            |
  42. | UserAuthentication                       | HASH(0x84119e8)                                            |
  43. +------------------------------------------+------------------------------------------------------------+
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement