is this something like anonymous sub but gets applied before code is compiled?
It is a (specially) named block, called by Perl before processing the rest of the module. See perlmod for details.
But I don't understand how to access sub BEGIN
What do you mean by "access sub BEGIN"?
If you mean how do you call it? You don't.
If you mean how do you use the package? I think the answer is that in the normal way of things you wouldn't. It appears to be a sub package of a larger suite that is intended to be called internally only. The one subroutine (method?!) it contains--that rather nastily, remotely insinuates itself in to a complete different package space--is a rather clumsy replication of exists.
Basically, once the module is loaded, the hash has been constructed. But, the BEGIN block is probably unnecessary. The module would work just the same without it.
And whenever anyone calls SOAP::Deserializer::typecast() passing ($self, $value, $name, $attrs, $children, $type), if $type exists in the hash, it returns $value, otherwise undef.
In reply to Re: sub BEGIN
by BrowserUk
in thread sub BEGIN
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |