|
| | Subject: | Re: Writing side of square | | Group: | Perl-beginners | | From: | Chas. Owens | | Date: | 5 May 2008 |
On Mon, May 5, 2008 at 11:18 AM, Stephen Kratzer <kratzers> wrote:
snip
> for (1..$n) {
> if ($_ == 1 || $_ == $n) {
> print "*" x $n, "\n";
> }
> else {
>
> print "*", " " x ($n - 2), "*\n";
> }
> }
snip
Its time to play TIMTOWTDI:
#!/usr/bin/perl
use strict;
use warnings;
my $n = 10;
my $i = $n - 2;
print "*" x $n, "\n", (map "*"." " x $i."*\n", 1 .. $i), "*" x $n, "\n";
print "*" x $n, "\n", ("*", " " x $i, "*\n") x $i, "*" x $n, "\n";
--
Chas. Owens
wonkden.net
The most important skill a programmer can have is the ability to read.
--
To unsubscribe, e-mail: beginners-unsubscribe
For additional commands, e-mail: beginners-help
http://learn.perl.org/
|