Hallo Struppi
Das Script ist wohl doch nicht sehr nützlich.
Der untenstehende Test verdeutlicht es.
  
#!usr/bin/perl -w  
#  
use strict;  
use CGI::Carp qw(fatalsToBrowser);  
  
BEGIN {  
 use CGI::Carp qw(carpout);  
 open(LOG, ">>error.txt")  or  die "Unable to append to error.txt: $!\n";  
 carpout(*LOG);  
}  
  
  
  
use constant NL => "\n";  
  
package Accessor;  
  
  
sub new {  
  my $proto = shift;  
  my $p = shift || 'x_';  
  my %dummy;  
  no strict 'refs';  
  foreach my $func (qw(a b c)) {  
         *{"${proto}::$p$func"}   = sub {  
       my $self = shift;                  ## sic!  
       $dummy{$func} = $_[0] if @_;  
       return $dummy{$func};  
     };  
   }  
  my $self = bless \%dummy, $proto;  
  return $self;  
}  
  
  
  
  
package main;  
  
# TEST  
  
print NL;  
my $y = new Accessor('y_');  
$y->y_a('$y, y_');  
print '$y->y_a() : ', $y->y_a(), NL;  
  
print NL;  
my $x = new Accessor('x_');  
$x->x_a('$x, x_');  
print '$y->x_a() : ', $y->x_a(), NL;  
print '$y->y_a() : ', $y->y_a(), NL;  
print '$x->x_a() : ', $x->x_a(), NL;  
print '$x->y_a() : ', $x->y_a(), NL;  
  
print NL;  
my $z = new Accessor('z_');  
$z->z_a('$z, z_');  
print '$z->x_a() : ', $z->x_a(), NL;  
print '$z->y_a() : ', $z->y_a(), NL;  
print '$z->z_a() : ', $z->z_a(), NL;  
  
sleep(20);  
  
exit;  
__END__  
Die Instanz $z hat vollen Zugriff auf die Eigenschaften von Instanzen $x und $y.
mfg Beat
-- 
Selber klauen ist schöner!
  Selber klauen ist schöner!