http://www.perlmonks.org?node_id=152189


in reply to Should I write your code ?

Hi ChOas you might note that what I posted at 19:04 (an hour before caillte for what it is worth) indicated the bugs in your posted code.

Should I give you hints, or should I write your code?

This is completely your choice. Your hint (check the result of rename and print the error in $! was excellent and got a ++ Give a man a fish and he will eat today. Teach a man to fish and he shall eat forever. On the other hand your example code was broken and got a -- When I noted that it had quite a high reputation it also got a direct reply to you. I feel if you post code it should work properly otherwise it does no one any good

Trying to rename a file, and failing to do so (for any reason), should result in an error message, and should not be quietly dismissed.

You are of course correct. While throwing an exception with die is one way of dealing with errors it is usually not a good way in a CGI. I usually have a die_nice() function in my CGIs that looks something like:

sub die_nice { my $real_error = shift; email($administrator, $real_error); log_error(scalar localtime, $real_error); tell_user('Sorry the system can not respond to your request due to + routine maintenance <br>Please try again later') # yeah, right! exit; }

One problem with a simple print is that without a valid header a CGI will fall over with a 500 internal server error.

You seem to have taken it a little to heart so may be amused to find that I have posed similar questions to yours at What's a fair thing? and So it's homework - so what? All the best and keep up the good work. ++ for this one BTW.

cheers

tachyon

s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print