Listing 7: Print-appointments-with-shai.pl

#!/usr/bin/perl -w
use strict;
use diagnostics;
use People;
use Appointments;
# Create an instance of People
my $people = new People;
# Create an instance of Appointments
my $appointments = new Appointments;
# Set the current person by name
$people->set_current_person_by_name("Shai", "Re'em")
   || die "Error retrieving person.";
# Retrieve today's appointments
my @appointments = $appointments->get_today_with_person($people);
# Iterate through each appointment
foreach my $appointment (@appointments)
{
    # Each appointment is a hashref, so print
    # its elements
    print $appointment->{start_time}, ":\t";
    print "\t", $appointment->{first_name},
        " ", $appointment->{last_name}, "\n";
    print "\t", $appointment->{notes}, "\n";
}