Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re^3: using AUTOLOAD to access read-only data structures

by ikegami (Pope)
on Jun 02, 2011 at 06:33 UTC ( #907757=note: print w/ replies, xml ) Need Help??


in reply to Re^2: using AUTOLOAD to access read-only data structures
in thread using AUTOLOAD to access read-only data structures

$foo doesn't hold an object that stringifies to Blorf or throws a better error on method call.


Comment on Re^3: using AUTOLOAD to access read-only data structures
Select or Download Code
Replies are listed 'Best First'.
Re^4: using AUTOLOAD to access read-only data structures
by shmem (Canon) on Jun 02, 2011 at 06:39 UTC
    Thanks, got it. Sometimes I'm slow.

    update: something like that would do:

    ... sub import { shift; $config or $config = XMLin(shift) if @_; $XSConf::strict = shift if @_; return; # don't give $config away } .... ref $thing and $token = $thing or return bless \$thing, XS +Conf::Str; } } return $package; } package XSConf::Str; use overload '""' => \&str, fallback => 1; sub str { ${$_[0]} } our $AUTOLOAD; sub AUTOLOAD { return if $AUTOLOAD eq 'XSConf::Str::DESTROY'; my @caller = caller; die "you cannot invoke the method '$AUTOLOAD' on the string '$_[0] +'" . " at $caller[1] line $caller[2]\n" if $XSConf::strict; $_[0]; } 1;

    update: added $XSConf::strict, caller and die

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://907757]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (8)
As of 2015-07-08 03:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (94 votes), past polls