YAPC::2004::Israel << Previous | Index | Next >> Copyright © 2004 Gaal Yahas

Class::Accessor


  • Pure Perl

  • Easy interface

     package TrafficLight;
     use base 'Class::Accessor';
     __PACKAGE__->mk_accessors(qw/color/);
     $light->color("yellow");
     print "The light was " . $light->color . ", sir";
  • Fast, too.

    • Generates closures for accessors, then puts them in the symbol table

    • No AUTOLOAD, $light->colour raises an exception