Here is sample code to excercise our object. Note the
constructor invocation, the setting and getting of attributes, and the
use of our general purpose method.
#!/usr/bin/perl -w
use strict;
use Person; # Define the class we are using, assume current directory
my $him; # Declare variables
my @All_Recs; # Declare variables
###################################
# Create and initialize an object #
###################################
$him = Person->new(); # Create a new object
$him->name("Jason"); # Set the "name" attribute in this object
$him->age(23); # Set the "age" attribute in this object
$him->peers( "Norbert", "Rhys", "Phineas" ); # Set the "peers" attribute
###################################
# Get the attributes of the object #
###################################
printf "%s is %d years old.\n", $him->name, $him->age;
print "His peers are: ", join(", ", $him->peers), "\n";
##################################
# Use one of the objects methods #
##################################
print "Using Report Function:\n";
print $him->report();
############################################
# Look Ma! I'm using an array of objects! #
############################################
push @All_Recs, $him; # save object in array for later
printf "Last rec's name is %s\n", $All_Recs[-1]->name;