A couple of thoughts further to ELISHEVA's comments.
The normal convention is to use x to represent left and right and y for up and down. You might want to swap your $x and $y to avoid confusion.
Rather than employing a for loop to iterate over every line you want to print, consider printing your "solid" top border then using the for to iterate over 2 fewer lines than your total y dimension whilst printing the "hollow" lines then finally printing the "solid" bottom border. That way, you have no need to detect where you are in the loop.
Consider putting this code in a subroutine, passing your dimensions as arguments (see perlsub) as a further learning exercise. Think about doing some basic validation, e.g. how would you cope with a negative or non-numeric dimension?
I hope these thoughts are helpful.
Cheers,
JohnGG
In reply to Re^3: Printing a hollow square of Asterisks
by johngg
in thread Printing a hollow square of Asterisks
by Rafter
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |