www.perl.com
Perl Programming
Arrow Operator
  • Arrow operator (->) is used to call methods.
  • Class (or static) methods are called on the class.
  • Object methods are called on a particular object.

        # Create a new MyCar object using a class method (constructor)
        my $car = MyCar->new();

        # Access data from the new object using an object method (accessor)
        print "The car has " . $car->gas() . " gallons of gasoline.\n";

        # Modify data
        for (1..10) {$car->accelerate();}
        print "The car has " . $car->gas() . " gallons of gasoline.\n";
      

        The car has 10 gallons of gasoline.
        The car has 9 gallons of gasoline.
      
Previous http://stuff.mit.edu/iap/perl/