This rather defeats the point of OO arch. Presumbably you want to do this:

$obj->{attibute} # instead of $obj->get_attribute();

Which given that most object are just blessed hashes you can do right now.....

package Foo; use Data::Dumper; my $o = new Bar; print $o->get_attribute(), $/; print $o->set_attribute('new val'), $/; print $o->set_flubber('dubber'), $/; print "Direct access, interpolated get flubber = $o->{flubber}\n"; print $o->no_exist(); print Dumper $o; package Bar; sub new{ return bless { attribute => 'value' }, shift } sub AUTOLOAD { my $self = shift; my ( $func ) = $AUTOLOAD =~ m/::([^:]+)$/; if ( $func =~ s/^set_// ) { return $self->{$func} = shift; } elsif ( $func =~ s/^get_// ) { return exists $self->{$func} ? $self->{$func} : undef; } else { my @caller = caller(); warn "Non existant function $func() called by:\n@caller\n"; return 0; } } sub DESTROY{}

cheers

tachyon

s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print


In reply to Re: bless + tie by tachyon
in thread bless + tie by cbraga

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.