I have been writing Perl for a relatively short time, and am just starting to make code that is useful. I wrote the following script to create mksysbs for my unix boxes. It runs from a central location on a NIM box, and creates the mksysbs. It checks to see if any of the mksysbs are old, and deletes them if they are. I humbly submit my code in hopes that someone can take a look and offer pointers. A better way to do things, or a different way, or a more efficient way, or anything that occurs to you that a perl initiate should know. Thanks.
# ====================================================================
+==
#
# NAME: mksysb.pl
#
# AUTHOR: TechFly
# Email: TechFlyG<a~t>Gmail
# DATE : 7-13-2010
#
# PURPOSE: Create an mksysb of servers listed in $path\mksysb.conf.
# Also, purge all mksysb's that are over an age set by the
# filemaxage parameter.
#
# ====================================================================
+==
use strict;
use warnings;
my $confpath;
my $servername;
my $filepath;
my $filemaxage;
$confpath = "/export/mksysb";
$filepath = "/export/mksysb";
$filemaxage = "360";
open(FILE, '<', "$confpath/mksysbmachinelist.conf") or die $!;
while(<FILE>){
chomp($servername = $_);
if (-e "$filepath/$servername") {
print("\n\n$servername\n");
}else{
print("\n\n$servername does not exist\n");
mkdir("$filepath/$servername");
}
foreach(<$filepath/$servername/$servername*>){
print "$filemaxage";
if (-M $_ > "$filemaxage"){
print(" $_ will not be purged\n");
}else{
unlink($_) or print ("Cannot delete file $!");}
}
system("nim -o define -t mksysb -a server=master -a mk_image=yes -a lo
+cation=$filepath/$servername/$servername\_`date +%m%d%Y` -a source=$s
+ervername $servername\_`date +%m%d%Y`");
}