Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Blob Maker

by legolas (Acolyte)
on Aug 21, 2002 at 03:17 UTC ( #191647=sourcecode: print w/ replies, xml ) Need Help??

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);

Comment on Blob Maker
Download Code
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; }

Back to Code Catacombs

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: sourcecode [id://191647]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (10)
As of 2014-07-28 10:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (195 votes), past polls