Hi

The other day, I confidently told a colleague that it was better to
use Scalar::Util::reftype to check e.g. whether a scalar holds a
reference to an array:

    if ( reftype( $param ) && reftype( $param ) eq 'ARRAY' ) {

instead of using CORE::ref

    if ( ref( $param ) eq 'ARRAY' ) {

I mentioned this was what PBP recommended. He asked me what the
reasoning was, which was the point where I thought "err....."

All I can come up with is that reftype is easier to read because it
returns what it sounds like it returns, whatever you give it, whereas
ref returns the class of an object, or if it's not an object then the
type of a reference.

Are there any other reasons? We also noted that CORE::ref returns an
empty string if there is no return value, whereas reftype returns
undef, which seems like an extra pain..

Alex
_______________________________________________
BristolBathPM mailing list
[email protected]
http://mailman.bristolbath.org/mailman/listinfo/bristolbathpm

Reply via email to