An alternate possibility would be to use the magic of the AUTOLOAD subroutine, to access data. This would allow for greater simplicity, when it comes to adding methods.
our $AUTOLOAD; sub AUTOLOAD { my $self = shift; ref($self) or return; # Non-OO/Not an autoloaded method..? return if ( $AUTOLOAD =~ /DESTROY/ ); # don't mess with garbage +collection ( my $method = $AUTOLOAD ) =~ s{.*::}{}; my ( $code, $name, $ATTRname ); if ( $method =~ /get_(\w+)/ ) { my $ATTRname = lc($1); # Could possibly do a check to make sure we have one of a group o +f specific # attributes with. # # if ( $ATTRname =~ /^(?:html_error_string|error_type|password_va +lid|user_id # |other|stuff|you|want|to|access)$/x # ) {} no strict qw{refs}; # create and register the method *{$AUTOLOAD} = sub { my $self = shift; return $self->{$ATTRname}; }; unshift @_, $self; goto &{$AUTOLOAD}; } return; }


Gyan Kapur
gyan.kapur@rhhllp.com

In reply to Re: Returing Multiple Items and possibly using an object by Revelation
in thread Returing Multiple Items and possibly using an object by Angel

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.