well it still did not compile /usr/bin/perl /oven_script/tst/dlt30day-oven1d-j3.pl Global symbol "$file" requires explicit package name at /oven_script/tst/dlt30day-oven1d-j3.pl line 14. Execution of /oven_script/tst/dlt30day-oven1d-j3.pl aborted due to compilation errors. so it hates $file
#!/usr/local/bin/perl # 2592000 = 30 day n min (60 *60 * 24 *30 ) use strict; use POSIX; use warnings; # change the below to dlt - dl30 my $logfile = "/script_logs/30DyDlt.txt"; my $date = localtime(); my $dir = '/oven_web/iportal/cgi-bin/uploads'; opendir(DIR,$dir) || die "Can't open $dir : $!\n"; my @files = readdir(DIR); # you may want to grep only certain files he +re close(DIR); ### my $logmsg = $date/$dir/$file; my $logmsg = "$date/$dir/$file"; #print $logmsg = $date/$dir/$file; open LOGFILE, ">> $logmsg " or die " cannot open logfie $logfile for a +ppend $!"; foreach my $file(@files) { my $now = time; my @stat = stat("$dir/$file"); if ($stat[9] < ($now - 2592000)) { print "Deleting $dir/$file..."; #unlink("$dir/$file"); #print "Done.\n"; print LOGFILE "$logmsg \n"; } } close LOGFILE;
so - i ( just for fun ) tried a my $file = "aaa" thinking explictedly declare it a value and later it gets the real fileNames -- or i was curious what wod happen...
#!/usr/local/bin/perl # 2592000 = 30 day n min (60 *60 * 24 *30 ) use strict; use POSIX; use warnings; # change the below to dlt - dl30 my $logfile = "/script_logs/30DyDlt.txt"; my $date = localtime(); my $dir = '/oven_web/iportal/cgi-bin/uploads'; my $file = "aaa" opendir(DIR,$dir) || die "Can't open $dir : $!\n"; my @files = readdir(DIR); # you may want to grep only certain files he +re close(DIR); ### my $logmsg = $date/$dir/$file; my $logmsg = "$date/$dir/$file"; #print $logmsg = $date/$dir/$file; open LOGFILE, ">> $logmsg " or die " cannot open logfie $logfile for a +ppend $!"; foreach my $file(@files) { my $now = time; my @stat = stat("$dir/$file"); if ($stat[9] < ($now - 2592000)) { print "Deleting $dir/$file..."; #unlink("$dir/$file"); #print "Done.\n"; print LOGFILE "$logmsg \n"; } } close LOGFILE;
well that blew up in the following manner ::: /usr/bin/perl /oven_script/tst/dlt30day-oven1d-j3.pl "my" variable $file masks earlier declaration in same scope at /oven_script/tst/dlt30day-oven1d-j3.pl line 20. syntax error at /oven_script/tst/dlt30day-oven1d-j3.pl line 11, near "opendir" Execution of /oven_script/tst/dlt30day-oven1d-j3.pl aborted due to compilation errors. hummmmm

In reply to Re^4: how to log a process by zimbot
in thread how to log a process by Anonymous Monk

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.