in reply to Re^2: Can I learn more about blessed data?
in thread Where can I learn more about blessed data?

> Then I found a great book, and then the holy grail...

Look, imagine someone asking for a book about "Churches", because he needs to understand this "Religion" (which is probably Christianity)...

That's how confusing your question sounds.

Blessing is just a mechanism from Object Oriented Programming.

you could also see it from a "typing" perspective:

Perl has data with primitive types, like arrays, hashes and scalars (including subtypes like integer, string, etc.)

These types have properties and methods. like length or keys

Blessing is a way to construct new types, with new properties and methods.

OOP is one application of that, and 99% of all objects you'll encounter in Perl are just blessed hashrefs.

There is no definitive book which will list all blessed data, because every module can create it's own, you have to check the documentation.

> I'm doing or who's module I am using I get data with just one !VAR,

Sounds like you are using Data::Dumper to display some JSON data.

JSON derives from Javascript which has an explicit "type" (sic) Boolean which doesn't exist in Perl. It's represented by "1" and ""/0 there, there is no TRUE and FALSE.

BUT when reading JSON data you often need to distinguish between the "1" and TRUE.

That's why JSON converters create a Perl object for boolean to represent this type

And Dumper will show something like bless \1, "Boolean" for true (or something similar)

HTH! :)

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery

Replies are listed 'Best First'.
Re^4: Can I learn more about blessed data?
by choroba (Cardinal) on Jan 08, 2021 at 18:44 UTC
    > Dumper will show something like

    In fact,

    $ perl -MData::Dumper -MJSON -wE 'print Dumper decode_json("[true]")' $VAR1 = [ bless( do{\(my $o = 1)}, 'JSON::PP::Boolean' ) ];
    Note that it returns the PP for all of JSON::PP, JSON::XS, and Cpanel::JSON::XS.
    map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]
      yes, \1 is read-only and can't be blessed, that's why they have to construct a scoped temporary scalar with my $o whose ref is returned by do

      Cheers Rolf
      (addicted to the Perl Programming Language :)
      Wikisyntax for the Monastery