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`"); }

In reply to check my code by TechFly

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.