Re: lvaluable AUTOLOAD (help! Abigail! someone!)



On May 6, 3:53 am, I wrote:
I decided I wanted to see if I could reproduce the effects of some
pretty common code in Perl. For instance, the Ruby version:
...
Is there away around this? Can I make this work?

BTW, I know of course I can easily do it without AUTOLOAD:

sub new($$$) {
my $class = shift;
my $self = {};

$self->{_vars}->{protected} = [qw(title)];
$self->{_discard} = undef;

bless $self, ref $class || $class;

$self->{title} = shift;
$self->{price} = shift;

return $self;
}

sub title {
shift->{title};
}

sub price : lvalue {
shift->{price};
}

That works fine. However, it seemed so strongly that I should be able
to do it with AUTOLOAD too...

--
Sean 'Dodger' Cannon
.



Relevant Pages

  • Re: New to Perl, OOP inheritance
    ... I'm new to Perl (from C, JavaScript, Ruby) and going through the Camel ... my $invocant = shift; ... sub toString { ...
    (comp.lang.perl.misc)
  • Re: Interfaces and Type Safety, Dynamic Typing (OOP Newbie in Perl)
    ... > sometimes Perl is not as defensive as I'd like. ... AUTOLOAD. ... compile-time as there is really not much code that needs to be compiled. ... It may be worthwhile to do a CPAN search for the string 'sub AUTOLOAD'. ...
    (comp.lang.perl.misc)
  • RE: returning hashes, and arrays
    ... :> subroutine named link(). ... :> array interchangeably here. ... : 'Learning Perl'; ... : sub ParseLineForHomeAndVisitors; ...
    (perl.beginners)
  • Re: Shifting Away
    ... are there two armed camps of Perl monks throwing gazillion megawatt ... daily at shift change and shout "When should I use an en dash?" ... become a bit less paranoid now but it's hard to let go of formal params. ... in the argument list and the sub could still change that. ...
    (comp.lang.perl.misc)
  • Re: Hardware hackers rejoice!
    ... I've tried to warm up to Perl ... sub getvar { ... # Given 0, the fan is off. ... # Display to LCD ...
    (Ubuntu)