in reply to Re: Whoops! I deleted everything!
in thread Whoops! I deleted everything!

Thanks for your insight. I was too confident about my code, so I let it run. Big mistake. I will always use warnings and do more testing in the future.

The problem is with your $days variable. You declared it with my() twice. Apparently, that results in some freakish behavior.

Is it really a bug? It just seems like it should work. Would it have worked properly if I hadn't used my() and just made $days global? What would be the best solution?

Replies are listed 'Best First'.
Re: Re: Re: Whoops! I deleted everything!
by sauoq (Abbot) on Dec 11, 2002 at 02:27 UTC

    Well, when you declare it twice, the first declaration overides the second and it is like the first one didn't exist at all. You could comment out the my $days = 31; and your program will behave exactly the same.

    It would have worked if $days was global but I don't think that's the best solution. I think the best solution is simply to remove the 'my' on the line where you set my $days = 7;. So just change that line to $days = 7; and that should do the trick.

    Of course, I still recommend testing thoroughly before actually allowing it to unlink files. ;-)

    -sauoq
    "My two cents aren't worth a dime.";