#!/usr/bin/perl

# on UNIX, use the chmod command to make this file executable, e.g. 
# chmod +x maxint.pl
# then just run this file like any executable, e.g. ./maxint
# no .pl suffix is needed since the shell will find it
# or invoke perl explicitly, e.g.
# this example causes Perl to run the program with warnings turned on
# perl -w -Mdiagnostics maxint.pl

use strict;  # an example of a pragma
use warnings;

my @aList = (5,3,7,12,4);
my $ans = maxint(@aList);
print "maxint of @aList is $ans\n";
 
sub maxint {
    if (@_ == 0) {
	0;
    } else {
	my $first = $_[0];
	my @newList = @_;
	shift @newList;
	my $max1 = maxint(@newList);
	if ($max1 > $first) {
	    return $max1
	} else {
	    return $first
        }
    }
}
