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

Your question is too general to be better answered, provide examples if you want more help.

My apologies. What I meant was depending on what I'm doing or who's module I am using I get data with just one !VAR, or sometime many more.

I feel like I do when I first started using Regex. Never thought I'd get there. Then I found a great book, and then the holy grail... RegEx101. Using that site I was able to figure my way around many different type of grep routines.

So I was hoping to find something like that, that would help tutor me.

  • Comment on Re^2: Can I learn more about blessed data?

Replies are listed 'Best First'.
Re^3: Can I learn more about blessed data?
by choroba (Cardinal) on Jan 08, 2021 at 16:11 UTC
    I see perlootut hasn't been suggested yet. Start there. Then go to bless and perlobj.

    map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]
Re^3: Can I learn more about blessed data?
by LanX (Saint) on Jan 08, 2021 at 18:32 UTC
    > 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

      > 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