My (untested) reworked version of your code is:

#!/usr/bin/perl use strict; use warnings; print "Backing up old timesNT.txt... \n"; rename ("timesNT.txt", "bac/timesNT.bac") || die "Cannot rename timesN +T.txt: $!"; open (NODELIST, "nodelistNT.txt") or die "I could not get at nodelist. +txt as input"; open (TIMES, ">>timesNT.txt") or die "I could not open times.txt as ou +tput"; my $time = localtime(time()); print TIMES "$time.--------------------------------------------------- +------------\n\n"; while (<NODELIST>) { chomp; my $name = $_; print "$name \n"; my $ntfile = "\"\\\\$name\\c\$\\WINNT\\Profiles\\All Users\\Applic +ation Data\\Network Associates\\VirusScan\\UpdateLog.txt\""; my $isfile = `dir /B $ntfile`; if ($isfile ne "") { my $fname = "//$name/c\$/WINNT/Profiles/All Users/Application +Data/Network Associates/VirusScan/UpdateLog.txt"; print "${name}'s system is NT!\n"; STUFF ($name, $fname); } else { my $fname = "//$name/c\$/Documents and Settings/All Users/Appl +ication Data/Network Associates/VirusScan/UpdateLog.txt"; print "${name}'s system is XP!\n"; STUFF ($name, $fname); } } close NODELIST; close TIMES; sub STUFF { my ($name, $fname) = @_; my $modded = -M $fname; return if $modded < 2; print TIMES "Server Name: $name\n"; print TIMES "$modded\n\n"; }

Note that "Eschew globals" and "Pass parameters" are related.

I was going to add something about removing cruft - removing the redundant use is good. I notice however that you used lowercase for the module name. You absolutly must use the correct case! Especially on Windows, which is case insensitive for file name, nasty and confusing things happen if the module case is not correct.

If you want to generate consistent formatting you might want to take a look at Perl::Tidy.


DWIM is Perl's answer to Gödel

In reply to Re^3: Has McAfee UpdateLog.txt been updated recently by GrandFather
in thread Has McAfee UpdateLog.txt been updated recently by Sunnmann

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.