in reply to check my code
my $confpath; my $servername; my $filepath; my $filemaxage; $confpath = "/export/mksysb"; $filepath = "/export/mksysb"; $filemaxage = "360";
The usual practice is to define and initialize variables in the same step:
my $confpath = '/export/mksysb'; my $filepath = '/export/mksysb'; my $filemaxage = 360;
By the way, $confpath and $filepath have the same value so is there really a need for two variables?
while(<FILE>){ chomp($servername = $_);
That is usually written as:
while ( my $servername = <FILE> ) { chomp $servername;
if (-M $_ > "$filemaxage"){
You are converting $filemaxage to a string and then Perl has to convert it back to a number in order to do a numerical comparison.
What's wrong with always quoting "$vars"?
mkdir("$filepath/$servername"); 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`");
You should also check for failure with mkdir and system like you already do with open and unlink.
|
|---|