possible mis-use of single-quoting if you are on W32? Or, try:
#!/usr/bin/perl -l use strict; use warnings; my $n = shift; # assign the number provided as an argue +ment 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 ; }
Tested on *nix and W2k
In reply to Re^5: Printing a hollow square of Asterisks
by ww
in thread Printing a hollow square of Asterisks
by Rafter
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |