|The stupid question is the question not asked|
debugging trick of the week: fatal warningsby gav^ (Curate)
|on Apr 26, 2002 at 00:54 UTC||Need Help??|
I apologise if this is something obvious but I only really discovered this recently. Using the pragma: use warnings FATAL => qw(all);
means that any warning will cause your script to die.
I find this really useful in debugging scripts that do a lot of data processing. It can stop those embarassing problems when you are trying to sell your client's products for undef dollars :)
In an processing script, I output the unique id of each item as it is processed, then if (when) it dies it's just a matter of digging through the database or input files to find out what's wrong with that item.
I've always considered it better to have my script die and then try to fix the data rather than having a 'robust' script that outputs gibberish in boundary cases.
Hope this helps somebody.