in reply to Printing a hollow square of Asterisks

Tough to beat JavaFan's, but here's a fairly plain-English method:

use strict; use warnings; my $x = 4; # width my $y = 2; # number of "hollow" rows my $solid = '*' x $x . $/; my $hollow = '*' . ' ' x ($x-2) . '*' . $/; print $solid, ($hollow) x $y, $solid;

Replies are listed 'Best First'.
Re^2: Printing a hollow square of Asterisks
by Rafter (Initiate) on Mar 04, 2009 at 18:56 UTC
    thank you so much... it works

      Now tell us how you think it works and explain each interesting line. Marks will be awarded according to the quality of your answer.

      Also identify any situations where it will fail and suggest appropriate handling for those situations.


      True laziness is hard work