Good morning monks. Today I figured I'd post this little script I wrote. It's not that cool and you can propbably point out errors in my writing/syntax style, so feel free to yell at me :)
#!/usr/bin/perl # Put on your nerd glasses and draw a square! use strict; use warnings; my $balancex = 10; # width my $repeatx = $balancex; #don't change repeatx!!! use balancex instead +. my $repeaty = 10; # height do{ while($repeatx > 0){ print ". "; # change the period to print another character, but ke +ep the extra space. $repeatx -= 1; } print "\n"; $repeatx += $balancex; $repeaty -= 1; } until ($repeaty == 0); #corrected by Athanasius & AppleFritter
No doubt this could be done in much fewer lines, or even as a one-liner :P But as it says it draws a square with periods, and is just fun to look at.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Draw a Square With Perl!
by Athanasius (Archbishop) on Aug 14, 2014 at 15:09 UTC | |
|
Re: Draw a Square With Perl! (golf)
by toolic (Bishop) on Aug 14, 2014 at 15:14 UTC | |
|
Re: Draw a Square With Perl!
by AppleFritter (Vicar) on Aug 14, 2014 at 16:28 UTC | |
|
Re: Draw a Square With Perl!
by Dipseydoodle (Acolyte) on Aug 14, 2014 at 15:19 UTC |