Subversion Repositories sysadmin_scripts

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
71 rodolico 1
#! /usr/bin/env perl
70 rodolico 2
 
71 rodolico 3
use warnings;
4
use strict;
5
 
6
use YAML::Tiny;
7
use Data::Dumper;
8
 
9
my $input = join( '', <> );
10
 
11
 
12
my @data = Load($input);
13
my $hashref = $data[0];
14
 
15
#print Dumper( $hashref );
16
#die;
17
 
18
foreach my $group ( sort keys %$hashref ) {
19
   if ( $group ) { # only do a group header if it is not empty
20
      my $header = '#'x10 . " $group " . '#'x10;
21
      my $length = length( $header );
22
      print "\n" . join( "\n", ( '#'x$length, $header, '#'x$length ) ) . "\n";
70 rodolico 23
   }
71 rodolico 24
   foreach my $host ( sort keys %{$hashref->{$group}} ) {
25
      print "\nHost " . $host . "\n";
26
      foreach my $key ( sort keys %{$hashref->{$group}->{$host}} ) {
27
         print "$key $hashref->{$group}->{$host}->{$key}\n";
28
      }
70 rodolico 29
   }
30
}
31
 
71 rodolico 32
1;