|Pathologically Eclectic Rubbish Lister|
Re^9: Use of uninitialized value $picby afoken (Chancellor)
|on May 03, 2017 at 06:08 UTC||Need Help??|
warn just warns, but continues. This is obviously intended for warnings. Stuff that went wrong, but can and will be automatically fixed by the program. Something like "configuration file not found, will use defaults".
die aborts the program due to an error. Any statements following die won't be executed. As obviously as before, this is intended for errors. Stuff that went so wrong that the program can not fix the problem and has to abort. Something like "Input is not a valid file, can't continue".
The Clone() method generates a clone of the image on which you want to work. If Clone() fails, you have nothing to work on. This is a clear case for die, not for warn.
die has a second purpose, very similar to the first one: Exception handling.
Java (and C++, C#, Python, ...) people would perhaps write something like throw new FooBarException("bla bla") in a library and even in the main program. Perl people use die in the main program and also in the libraries. Java people use try and catch to handle exceptions, in Perl, you use eval (in the BLOCK variant) and check $@ if eval fails. eval prevents die from aborting the program, it just aborts the eval block.
The combination of eval and die has some nasty corner cases, so the usual idiom is to have eval return a true value and only check $@ if eval returns false:
Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)