I am creating a program that checks the first line of a file which has the date of the month init. It then moves that file into to corresponding folder. I.e a file from november into the "1-month-ago" folder. I am haveing trouble with one line. I am useing the code from
which states
use File::Copy;
$oldlocation = "myhtml.html";
$newlocation = "html/myhtml.html";
move($oldlocation, $newlocation);
but my program has an error on the move line, i don't know how much of my program to paste sorry as it is pretty big but here's a snip:
$date = substr($firstline,3 ,2); #Collect the month from the log
$N = 0;
until ( $N == 6) #Until all 6 months have been checked
{
@folder = qw( 1-month-ago 2-months-ago 3-months-ago 4-months-ago 5-months-ago 6-months-ago);
$month - 1; #Counts down 6 months
if ( $date == $month) #if the first line of the log equals the date
{
$oldlocation = "/perl/ass/@logfiles[$hour]"; #Cut and Pastes the log file into corresponding folder
$newlocation = "/perl/ass/@folder[$N]/@logfiles[$hour]";
move($oldlocation, $newlocation) or die "File cannot be moved."; #THIS LINE IS WERE THE ERROR STOPS THE PROGRAM
$N = 3;
$date = 999; #Makes the date not equal to any other date
}
$N++;
$history = $history - 7;
}
any help is much appreciated
Paul
which states
use File::Copy;
$oldlocation = "myhtml.html";
$newlocation = "html/myhtml.html";
move($oldlocation, $newlocation);
but my program has an error on the move line, i don't know how much of my program to paste sorry as it is pretty big but here's a snip:
$date = substr($firstline,3 ,2); #Collect the month from the log
$N = 0;
until ( $N == 6) #Until all 6 months have been checked
{
@folder = qw( 1-month-ago 2-months-ago 3-months-ago 4-months-ago 5-months-ago 6-months-ago);
$month - 1; #Counts down 6 months
if ( $date == $month) #if the first line of the log equals the date
{
$oldlocation = "/perl/ass/@logfiles[$hour]"; #Cut and Pastes the log file into corresponding folder
$newlocation = "/perl/ass/@folder[$N]/@logfiles[$hour]";
move($oldlocation, $newlocation) or die "File cannot be moved."; #THIS LINE IS WERE THE ERROR STOPS THE PROGRAM
$N = 3;
$date = 999; #Makes the date not equal to any other date
}
$N++;
$history = $history - 7;
}
any help is much appreciated
Paul