in reply to Object Oriented Perl - very basic guide

The way perl 'does' objects, is that it treats each object as a hash.
That's not the full story. In Perl, any reference can be blessed. Hashes are the easiest thing to make into an object, but people sometimes bless array references, too (they are a bit faster in tight loops). You can even bless a scalar (check XML::LibXML) or code reference...
لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ
  • Comment on Re: Object Oriented Perl - very basic guide

Replies are listed 'Best First'.
Re^2: Object Oriented Perl - very basic guide
by morgon (Priest) on May 15, 2014 at 15:27 UTC
    You can even bless a scalar
    Just for clarification (you meant that of course): You cannot bless a scalar, you can bless a reference to a scalar (as any other type of reference - I would recommend to bless a directory handle :-)
      You didn't quote the whole phrase: You can ever bless a scalar (...) or code reference.
      لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

        If you parse that as "(a ((scalar or code) reference)" then what you said wasn't wrong. However, if you parse that as "(a (scalar) or (code reference))" like morgon and I did, then you'll have to admit that morgon has a point.

        However, a reference is a scalar of course, so technically a claim that "you can even bless a scalar" isn't incorrect as much as it's redundant, given that you can only bless references :)