#!/usr/bin/perl
print "Recursive version of Maxint function!\n";  # a short Perl example

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

sub maxint {
    print "on entering maxint, the input list is @_\n";
    if (@_ == 0) {    # check for empty list
	0;
    } else {
	my $first = $_[0];
	my @newList = @_;
	shift @newList;     # remove first element of list
	my $max1 = maxint(@newList);
	if ($first > $max1) {
	    $first;
	} else {
	    $max1;
	}
    }
}

my @aList = (7,3,4,5);
print "the array is @aList\n";
my $max1 = maxint(@aList);
print "maxint of @aList is $max1\n";
