JUANMARCOSMOREN <JUANMARCOSMOREN@xxxxxxxx> writes:
>>You make a good point about global variables, however I felt it was
>>overridden by the importance of usable error reporting. The global $!
>>for error messages is rather ugly, but still any good beginner's Perl
>>tutorial recommends to always put $! in every error message.
>
>DO NOT USE GLOBALS!!!
>If a tutorial tells you to use a global variable then that's a bad
>tutorial!
Seriously? What do you use to report the failure of an open() call?
>>It looks like there is a niche for a library that makes it simple to
>>download URLs, but also makes it simple to do the right thing, which
>>in my opinion means always checking the success of each call and
>>giving an informative error message.
>
>As I said there's a "complicated" interface you should be using
>anyway, instead the crappy LWP::Simple.
I don't agree that LWP::Simple is crappy, I think it is a good library
except for the inability to do error reporting.
Anyway I am using the 'complicated' interface as you suggest. The
modified LWP::Simple code is a thin wrapper around LWP to do what I
want - fetch a URL, and report success or failure.
I am not that keen on global variables, I would much prefer for an
interface to throw an exception on error. This also makes a lot of
code simpler since you no longer have to explicitly check return
status - instead, you have to explicitly ignore or catch errors if you
want to do that. The patch with the global $LWP::Simple::err was only
because I thought it stood a better chance of getting accepted that
way.
--
Ed Avis <ed@xxxxxxxxxxx>
|