#!/usr/bin/perl -w

print "Please input the width of the base (1-50) > ";
chomp(my $input = <STDIN>);
if ($input < 1 or $input > 50) {
	die "Input must be in the range (1..50)!\n";
}

{
	my ($trend, $i) = (0, $input);
	while ($i <= $input) {
		if ($i == 1 or $i == 2) {
			$trend = 1;
		}
		print " " x (($input - $i)/2) . "*" x $i . "\n";
	} continue {
		$i += ($trend? 2 : -2);
	}
}
