I think the error is being generated by the destructor ("in cleanup") of an object going out of scope; in this case $session is the only plausible candidate. You can test this hypothesis by taking the code back out of the sub and sticking it in its own block off the top level, like this:
If the hypothesis is correct, this should also trigger the same error.{ my $sid = cookie('main') || undef; my @sessionInfo; my $session = new CGI::Session(undef, $sid, {Directory=>'c:/apache/s +essions'}); if ( $session->is_new() ) { $session->delete(); } else { # get values from session } }
If this is case, then the hard part is figuring out why the destructor is having problems. As usual, I'd fire up the debugger (perldb) and start following stuff around. Or you may use the tried and true print-statement debugging method to probe the status of the object created by the constructor. Are you running with warnings? If not, turn them on, just in case the constructor is emitting warnings about problems when creating the new instance. In particular, does the server have permission to write to directory mentioned in the error message? Does the file mentioned in the error message still exist after the program exits? Can you log the contents of the directory in question before exiting the problematic block, to see if the constructor succeeded in creating the file that the destructor is failing to unlink?
Update: One thing I should have mentioned from the get go is that if the destructor hypothesis is correct (and ikegami's idea with the warn statement is clearly a simpler way to nail it than what I proposed above of moving the code to a block off the top level yadda-yadda), then you should look for a subroutine called DESTROY in CGI/Session.pm, and just look at what that subroutine is attempting to do (that's the beauty of open source!). That'll give some good clues for why you are getting the error.
the lowliest monk
In reply to Re: Code works fine, but in subroutine does not... help plz!
by tlm
in thread Code works fine, but in subroutine does not... help plz!
by Stenyj
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |