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

Re: OO Perl and AUTOLOAD

by shemp (Deacon)
on Apr 08, 2005 at 12:54 UTC ( [id://446081]=note: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


in reply to OO Perl and AUTOLOAD

In the code you provided, you never directly look in the %_attribute_properties. It appears that your accessor only knows the type of the thing being accessed, because you have set the value with the mutator. If you modify the accessor so that it checks if the attribute exists, and if not, find the type of the attribute from the %attribute_properties, then the proper type should be returned.

As a nitpick, why not return references to the array and hash attributes, then you dont need to play dereferencing games, let the caller, because they need to know the type already...unless of course you want to return deep copies.

Replies are listed 'Best First'.
Re^2: OO Perl and AUTOLOAD
by tucano (Scribe) on Apr 14, 2005 at 07:48 UTC
    The next chapter of the story:
    # locations _locations => [ ['????'] , 'read.write.noinit.array' + ], _refseqposition => [ { } , 'read.write.noinit.hash' + ], # licrinfo _licr_info => [ ['????'] , 'read.write.noinit.array' + ],
    And type handler
    # Added Type handler sub _check_type { my ($self,$attribute,$type) = @_; $_attribute_properties{$attribute}[1] =~ /$type/; }
    Now AUTOLOAD works good from the caller! THANKS TO ALL!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://446081]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.