Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Perl Beginners > Re: Writing sid...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 4 of 4 Topic 11029 of 11532
Post > Topic >>

Re: Writing side of square

by chas.owens@[EMAIL PROTECTED] (Chas. Owens) May 5, 2008 at 05:18 PM

On Mon, May 5, 2008 at 11:18 AM, Stephen Kratzer <kratzers@[EMAIL PROTECTED]
> 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 im****tant skill a programmer can have is the ability to read.
 




 4 Posts in Topic:
Writing side of square
digolinopage@[EMAIL PROTE  2008-05-05 06:22:51 
Re: Writing side of square
rob.dixon@[EMAIL PROTECTE  2008-05-05 15:33:03 
Re: Writing side of square
kratzers@[EMAIL PROTECTED  2008-05-05 11:18:08 
Re: Writing side of square
chas.owens@[EMAIL PROTECT  2008-05-05 17:18:13 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat Jul 26 6:24:08 CDT 2008.