UPDATE: SOLUTION PROVIDED
I have a written a working Perl script (my first one). The interpreter complains when I turn on 'use strict'. I get the following error message: "Global symbol $files requires explicit package name at...line 19...line 20...line 24".
My code:
#!/usr/bin/perl use warnings; use strict; my @files; my $downloadpath = "/home/content/c/r/e/creatingzion/html/downloads"; my $timestamp = time(); my $modified_time; #[9] in the list of file attributes. my $age_of_file; my $time_to_live = 3600; #return a list of all the mp3 files in the downloadpath opendir(DIR, $downloadpath); @files = grep(/\.mp3$/,readdir(DIR)); closedir(DIR); #end comment #compare each file's last modified time with the current time and dele +te any files older than the time to live in seconds. foreach $files (@files) { $modified_time = (stat($downloadpath."/".$files))[9]; print $modified_time; $age_of_file = $timestamp - $modified_time; if($age_of_file >= $time_to_live) {unlink($downloadpath."/".$files);} } #end comment
The only thing I can think of and only thing my research indicates is that I need to use a lexical variable. But I'm doing that already.
UPDATE: Thank you both for you help.
In reply to Global symbol .... requires explicit package name at by ZETZ
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |