#!/usr/bin/perl -l use strict; use warnings; my $n = shift; # assign the number provided as an arguement to $n die q{Please provide a positive number.} if ($n < 0); # not negative print q{*} x $n; # print "*" $n times followed by newline (the shebang's -l switch if ($n >1) { foreach (2 .. $n - 1) { # print second line .. next to last line print q{*}, q{ } x ($n - 2), q{*}; # with $n-2 spaces (first & last postions are * } print "*" x $n ; }