Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Blob Maker

by legolas (Acolyte)
on Aug 21, 2002 at 03:17 UTC ( [id://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);
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; }

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (2)
As of 2024-04-25 20:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found