Perl Programming | ||
---|---|---|
Methods Types | ||
# 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/ | Next |