Subject: | Can't rename error |
I have a program which loops around a bunch of feeds in a foreach loop.
For each feed it will then check for it in a statefile which is held
with the InPlace module. When certain conditions are met then it will
change the the line relating to the feed in the state file.
This seems to work for the first feed but then when the second feed
comes in it errors saying that the state file doesn't exist even though
it does.
Code out put
bash-3.00$ ./FeedMon.pl
-rw------- 1 aodyfog odyssey 153 Dec 17 10:15 /home/perl/State_File
after commit
-rw------- 1 aodyfog odyssey 153 Dec 17 10:20 /home/perl/State_File
Can't rename => /home/perl/State_File: No such file or directory at
./FeedMon.pl line 189
bash-3.00$
Problem code:
foreach my $feed(@feeds)
{
$feed = cleanstring($feed);
my $statefound = "false";
@tmparray = split(/ /,$feed);
$feedname = $tmparray[0];
$duedate = $tmparray[1];
if ( $feed ne "" && $firstrun eq "false" )
{
## Check for feed in state file
while (my ($stateline) = $editor->next_line) {
if ( $stateline ne "")
{
my @state = split(/,/ , $stateline);
if ( $state[0] eq $feedname )
{
$statefound = "true";
if ( $type eq "priority"
&& $state[2] ne $checkdate && $state[4] ne "Y" )
{
mail_out(
$feedname );
$editor->replace_line("$feedname,$duedate,$checkdate,$checktime,Y");
}
elsif ( $type eq "normal" )
{
if ( $state[2]
ne $checkdate )
{
$editor->replace_line("$feedname,$duedate,$checkdate,$checktime,N");
}
elsif (
$state[2] eq $checkdate && $state[4] eq "N" )
{
mail_out( $feedname );
$editor->replace_line("$feedname,$duedate,$checkdate,$checktime,Y");
}
}
}
}
}
system("ls -l $statefile");
$editor->commit;
print "after commit\n";
}