http://qs321.pair.com?node_id=191647
Category: Fun Stuff
Author/Contact Info Kevin Cohe
Description: This is a simple program that draws squares out of asterikses. I did it basically to learn about strings and loops. Nothing spectacular, but a fun program nonetheless.
#!/usr/bin/perl -w

print "Welcome to blob maker V1.1\n";

print "all you need to do is input the size of your 

blob\n";

print "and the computers built in gene sequencer ;-) will 

make your blob\n\n\n"; 

print "Input your blob's height\n";

$height=<STDIN>;

print "Input your blob's width\n";

$width=<STDIN>;

print "input blob message\n";

$msg=<STDIN>;

do{

print "$msg" x $width . "\n";

$height-=1;

}until($height==0);
Replies are listed 'Best First'.
Re: Blob Maker
by blakem (Monsignor) on Aug 21, 2002 at 05:24 UTC
    That certainly is a good start, but what happens to your loop if I enter a negative value for the height parameter?

    -Blake

Re: Blob Maker
by Anonymous Monk on Oct 07, 2006 at 18:37 UTC
    I have edited the message, improved readability, and corrected the negative value flaw; the only trouble is that it warns if there's a non-integer argument :(. I don't know how to correct this.
    #!/usr/bin/perl use warnings; use strict; print "Welcome to blob maker V1.2\n"; print("Input your blob's height: "); chomp(my $height=<STDIN>); $height=int($height); die("Invalid argument.\n") if ($height < 1); print("Input your blob's width: "); chomp(my $width=<STDIN>); $width=int($width); die("Invalid argument.\n") if($width < 1); print("Input blob message: "); chomp(my $msg=<STDIN>); print("\n"); while ($height > 0 ){ print("$msg" x $width . "\n"); --$height; }