On Thu, 16 Sep 2004 13:32:12 GMT, Chris <ceo / nospan.on.net> wrote:
[snip] 
> I actually wrote it anyway right after I posted the message above, just 
> to see what the difference would be:

Alternatively (tmtowtdi and all that ...):

  #!/usr/bin/perl -w
  use strict;

  my $foo = Foo->new('the');
  print $foo->concat, "\n";
  $foo->bar  = 'Das';
  $foo->boat = 'Boot';
  print $foo->concat, "\n";

  { 
    package Foo;
    my(%bar, %boat);
    sub new {
        my $self  = bless {}, shift;
        $self->$_ = shift || $_ for ('bar','boat');
        $self;
    }
    sub bar  : lvalue { $bar  {$_[0]}}
    sub boat : lvalue { $boat {$_[0]}}
    sub concat { $_[0]->bar . $_[0]->boat }
  }
  __END__

regards,
andrew