Keep It Simple, Stupid | |
PerlMonks |
Re^2: question about variables from new perl userby Apero (Scribe) |
on Dec 01, 2015 at 01:38 UTC ( [id://1148985]=note: print w/replies, xml ) | Need Help?? |
I couldn't find documentation on accessor methods Right, because a True/False boolean value does not have methods. The fact that LWP::Simple::head() returns an object is an undocumented side-effect as the API is described. Do not rely on this to be an object (and thus do not rely on any data in the object, object methods, accessors, and so on.) As I commented on earlier, I ventured a guess this class returned an object out of simplicity or convenience. The LWP::Simple class docs, however, are very clear that you get a "TRUE" (sic) value back from the function call. It's highly unwise to use it as a constructor. If you want to know what type an object is (and can't otherwise tell from documentation, which is where you should go to look for that fact,) you can do so with the ref() built-in call, like so:
Big fat warning: do not use this function's return as an object! This is merely a demonstration of how to determine an object's type. Please refer to the LWP documentation on how the object-oriented class is designed and what constructors return what types of objects to avoid unpleasant surprises later.
In Section
Seekers of Perl Wisdom
|
|