www.perl.com
Perl Programming
Methods Types
  • Constructors create new objects.
  • Accessors access an object's data.
  • Mutators modify an object's data.
  • Often a single method is an accessor and mutator.

        # Accessor Methods
        sub wheels {
          my $self = shift;
          return $self->{wheels};
        }

        sub speed {
          my $self = shift;
          return $self->{speed};
        }

        sub gas {
          my $self = shift;
          return $self->{gas};
        }

        # Mutator Methods
        sub accelerate {
          my $self = shift;
          $self->{speed} += 1;
          $self->{gas} -= 0.1;
        }

        sub brake {
          my $self = shift;
          $self->{speed} -= 1;
        }
      
Previous http://stuff.mit.edu/iap/perl/