ARS HDSrv Sch1 Demo Y ARS HDSrv Sch2 Demo Y ARS HDSrv Sch1 Demo pass N #### #! /usr/bin/perl use strict; use warnings; use XML::Simple; my ($mdlist, @mds, @dirs, $key, $callout_loc); $callout_loc = "."; my $file = "./mdlist.xml"; my $xs1 = XML::Simple->new(); eval { $mdlist = $xs1->XMLin($file, forcearray => 1, keyattr => 'name') }; if ($@) { print "Problems with Loading XML - $@\n"; exit(); } &Get_MDs(); &Get_Dirs(); #Check if Dir created else create it. map { &checkdir } @mds; ######################################################################################## ## ## SUB ROUTINES ## ######################################################################################## #Get List of MDs sub Get_MDs { foreach $key (keys (%{$mdlist->{md}})) { push(@mds, $mdlist->{md}->{$key}->{'name'} . $key); } } #Get list of dirs sub Get_Dirs { if ( opendir( MDDIR, "$callout_loc" ) ) { while( my $dir = readdir( MDDIR ) ) { next if( ( "." eq $dir ) || ( ".." eq $dir ) ); push( @dirs, $dir ) if( -d "$callout_loc/$dir" ); } closedir( MDDIR ); } else { #Could not OPEN Dir print "Could not open $callout_loc to check for MD Directories: $!\n"; exit (0); } } #Check if Dir Exists else Create. sub checkdir { print "Checking DIR for $_ ... "; undef my %dir_exists; for (@dirs) { $dir_exists{$_} = 1 } if (!$dir_exists{$_}) { print "Creating.\n"; mkdir ($_); } else { print " Exists\n"; } }