Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

Re: Should I write your code ?

by tachyon (Chancellor)
on Mar 16, 2002 at 14:37 UTC ( #152189=note: print w/replies, xml ) Need Help??

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.




Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://152189]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (5)
As of 2017-06-27 17:24 GMT
Find Nodes?
    Voting Booth?
    How many monitors do you use while coding?

    Results (611 votes). Check out past polls.