guys i have a Script was not written by me... that delete a particular file once it ages 7 days...
never the less, the script is not working as planed...
can someone help me out?
@fields = split( /\./, $logname );
$_ = $fields[1]; \# get roll over time
\# $1 $2 $3
\# Y Y Y Y M M D D
/\(\\d\\d\\d\\d\)\(\\d\\d\)\(\\d\\d\)/;
$year = $1 - 1900; <-----WHY 1900??
$month = $2 - 1; <----- one month back???
$day = $3;
$time\_of_log = timelocal\( 0, 0, 0, $day, $month, $year \);
if \($time\_of_log < $time_expired\)
\{
\# delete file
$filename = $dirname . "/" . $logname;
unlink $filename;
ERROR received,
Use of uninitialized value in subtraction (-) at ./script line 81.
Use of uninitialized value in subtraction (-) at ./script line 82.
Month '-1' out of range 0..11 at ./script line 85
I don't understand some of the lines here... is there a software that would show you the output for each line? i think that would help tremendously!
$logname doe not have a value. It appears to be a filename with an embedded date/time stamp.
UNIX time (internal) is a number of seconds since an arbitrary starting time.... 1900 is the 'earliest' year, so 2006 would be year 106 which is 2006 - 1900.
Months start counting from zero ie., Jan = zero , Feb = 1....
Thanks jim... i believe the 1900 is the epoch year right?.. okay...
then something is wrong...
it seems that i earlier suspected that it could be the assignment of values, but reborg confirms that its correct... hmmmm...
is my filename is 20060726160000.20060727160000.xxxxxxxxxx
and i would just like to use the 20060726 part, so i just include in the brackets... but attach no variables to it?
\# $1 $2 $3
\# Y Y Y Y M M D D
/\(\\d\\d\\d\\d\)\(\\d\\d\)\(\\d\\d\)\(\\d\\d\\d\\d\).\(\\d\\d\\d\\d\)\(\\d\\d\)\(\\d\\d\)\(\\d\\d\\d\\d\).//;
Come on. Learn some Perl first and look for some of the beginner's tutorials online first. Don't really expect to use Perl effectively without any reading. It is not going to work.
sorry... i agree with you about learning up alil... but perl isn't really my thing.. it just happens.. that i need to modify this script to get it work...
i'm sorry for posting such questions... but thanks anyways for trying to help...
appreciate it..
There's nothing wrong posting these questions. But what I would like to say is the fact, that if you do not have some prior learning on your side, you are unlikely to arrive at the answer on your own the next time and you will learn nothing, relying on others to give you the answers.
cbkihong... I agree with what you say.. i'll make it a point to read something up when i have the time... and i bear no grudges on you for what you say.. i know you mean well... thanks