Problems? Is your data what you think it is? | |
PerlMonks |
Re: Blessing with unknown classnames (updated x 2)by LanX (Saint) |
on Apr 01, 2021 at 16:44 UTC ( [id://11130678]=note: print w/replies, xml ) | Need Help?? |
> What happens when a ref is blessed into a non-existent class. Afterall bless's 2nd argument is a string and not a package qualifier. You don't reveal the answer on purpose? The package/class is created. you can check by inspecting the %main:: stash, where all packages live
and I think ° it's not only the typeglob but also the stash %nonexistent:: is created, which will result in several hundreds of bytes of overhead
So better don't try to automatically bless into millions of pseudo packages ...
Cheers Rolf PS: According to some statistics this was my 10000st post here ... frightening.
update°) I couldn't find a pure Perl way to check if the HASH slot of a package:: like entry is filled, without autovivifying that package. It's a very quantum-brainf*ck thing, the observation is changing the result.
UpdateFor clarification: using bless to solve the semipredicate problem is totally fine in my eyes. Just be aware that the package will exist. And this globally. So you should care about a naming convention in your own namespace.
In Section
Seekers of Perl Wisdom
|
|