usr/bin/perl -- ## 2015-09-21-18:21:28 ## ## ## ## ## ## perltidy -olq -csc -csci=3 -cscl="sub : BEGIN END " -otr -opr -ce -nibc -i=4 -pt=0 "-nsak=*" ## perltidy -olq -csc -csci=10 -cscl="sub : BEGIN END if " -otr -opr -ce -nibc -i=4 -pt=0 "-nsak=*" ## perltidy -olq -csc -csci=10 -cscl="sub : BEGIN END if while " -otr -opr -ce -nibc -i=4 -pt=0 "-nsak=*" ## perltidy -olq -csc -csci=10 -cscl="sub : BEGIN END if while for " -otr -opr -ce -nibc -i=4 -pt=0 "-nsak=*" #!/usr/bin/perl -- use strict; use warnings; use Path::Tiny qw/ path /; Main( @ARGV ); exit( 0 ); sub Main { my @files = path( "Configs/" )->children; for my $file ( @files ) { FaFyle( $file ); } } ## end sub Main sub FaFyle { my( $file ) = @_; my $config = ReadConfig( $file ); NaNameConfMod( $config ); ObObjectsConfMod( $config ); } ## end sub FaFyle sub ReadConfig { return [ path( $_[0] )->lines_raw( { chomp => 1 } ) ]; } ## end sub ReadConfig sub NaNamesConfMod { my( $configref ) = @_; my @names = map { /^name \d+\.\d+\.\d+\.\d+ ([A-Za-z0-9-_]+)$/ ? $1 : () } @{$configref}; @{$configref} = grep { $_ !~ /^name / } @{$configref}; FaFindCb( sub { print "name $_[0] unused\n" }, \@names, $configref ); return; } ## end sub NaNamesConfMod sub ObObjectsConfMod { my( $configref ) = @_; my @objects = map { /^(object|object-group) (network|service) ([A-Za-z0-9-_]+)$/ ? $3 : () } @{$configref}; @{$configref} = grep { $_ !~ /^(object|object-group) / } @{$configref}; FaFindCb( sub { print "object $_[0] unused\n" }, \@objects, $configref ); return; } ## end sub ObObjectsConfMod sub FaFind { my( $callback, $objects, $config ) = @_; foreach my $object ( @$objects ) { if( !grep { $_ =~ /\Q$object\E/ } @{$config} ) { $callback->( $object ); } } } ## end sub FaFind __END__ __END__