From: Marco Antonio Valenzuela Escárcega <[EMAIL PROTECTED]> > On Sat, 2002-06-22 at 21:27, drieux wrote: > > > > volks, > > > > I'm playing around with a little perl module and I came > > across to different solutions - thought I would ask for > > opinions as to which would be more Kosher - so why not > > ask folks who might have an opinion: > > > > Plan A: The simple 'undef' trick > > Plan B: your basic Croak Play > I think Plan A is a more general solution, because maybe there will be > some times when you don't want a warning, instead you'll want to be > able to make some test:
You are missing one thing. The croak() message doesn't have to get printed to the user, it might get caught. See perldoc -f eval perldoc -f die So in either case it is possible to catch the error and handle it. I do not think either of the solutions is generaly better. The first one is easier if you are going to test for the success of every action and act accordingly, the second if you want to do several actions and if any of them fails skip the rest, without having to care whether you are falling out of procedures, or needing to pass around the error code/state. The second way is a bit safer though. If you forget to test for errors, your script ends with an error message and the user knows something went wrong. If you use the first and ignore the function result everything seems to be OK, user thinks it worked and it blows up later. Jenda =========== [EMAIL PROTECTED] == http://Jenda.Krynicky.cz ========== There is a reason for living. There must be. I've seen it somewhere. It's just that in the mess on my table ... and in my brain I can't find it. --- me -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]