Ask a Question related to PERL Beginners, Design and Development.
-
Trent Rigsbee #1
Re: Counting (easy!) (YES!!)
I think I figured it out! A FIRST!!
for ($i = 1; $i <= 5; $i++){
sleep 1;
print "$i\n";
}
I prints out like this: 1...2...3...4...5
YES!!
Thanks everyone! :-)
__________________________________________________ _______________>From: "Trent Rigsbee" <sweetdaddysiki@hotmail.com>
>To: [email]beginners@perl.org[/email]
>Subject: Counting (easy!)
>Date: Thu, 13 Nov 2003 01:05:37 +0000
>
>I'm sure this is easy but I'm a newbie. I was doing control statements
>(for, while,etc.) like this:
>
>for ($count = 1; $count <= 5; $count++) {
> print "$count\n";
>}
>
>What I wanted to do was to make each number appear in sequence like you see
>in a countdown (or up, in this case) instead of all on the screen at once.
>I've tried using sleep but I'm not getting anywhere with it. Any ideas?
>Also, any methods or ideas on how to approach creating code in general? For
>example, what's the thought process for trying to do what I want to do?
>I've tried pseudo code and it's helped some but then I hit the wall and
>don't how to go further. Thanks!
>
>_________________________________________________ ________________
>Frustrated with dial-up? Get high-speed for as low as $26.95.
>[url]https://broadband.msn.com[/url] (Prices may vary by service area.)
>
>
>--
>To unsubscribe, e-mail: [email]beginners-unsubscribe@perl.org[/email]
>For additional commands, e-mail: [email]beginners-help@perl.org[/email]
>
Send a QuickGreet with MSN Messenger
[url]http://www.msnmessenger-download.com/tracking/cdp_games[/url]
Trent Rigsbee Guest
-
Counting (easy!) - select???
Christiane Nerz wrote: It's used in this case for sleeping for less than one second. The sleep() function only sleeps for a whole number of... -
Counting (easy!)
I'm sure this is easy but I'm a newbie. I was doing control statements (for, while,etc.) like this: for ($count = 1; $count <= 5; $count++) {... -
search for email address in file, was Counting (easy!)
Please choose a subject that is reflective of your post and start a new thread when appropriate... would I The @ in the above does need to be... -
Easy question = easy answer?
Well, so I'm pretty new with Freehand, at the mo running with MX and havin' a problem (not big, but anyway)... I'm creating some cards and they... -
Easy Question/Easy Answer
Ok, this is all i want to know how to do, i made a text link, now when someone rolls over it with their pointer i want it to change color. Simple? -
Tim Johnson #2
RE: Counting (easy!) (YES!!)
Wouldn't that print out
1
2
3
4
5
?
-----Original Message-----
From: Trent Rigsbee [mailto:sweetdaddysiki@hotmail.com]
Sent: Wednesday, November 12, 2003 6:13 PM
To: [email]beginners@perl.org[/email]
Subject: Re: Counting (easy!) (YES!!)
I think I figured it out! A FIRST!!
for ($i = 1; $i <= 5; $i++){
sleep 1;
print "$i\n";
}
I prints out like this: 1...2...3...4...5
YES!!
Thanks everyone! :-)
>From: "Trent Rigsbee" <sweetdaddysiki@hotmail.com>
>To: [email]beginners@perl.org[/email]
>Subject: Counting (easy!)
>Date: Thu, 13 Nov 2003 01:05:37 +0000
>
>I'm sure this is easy but I'm a newbie. I was doing control statements
>(for, while,etc.) like this:
>
>for ($count = 1; $count <= 5; $count++) {
> print "$count\n"; }
>
>What I wanted to do was to make each number appear in sequence like youat once.>see in a countdown (or up, in this case) instead of all on the screen>I've tried using sleep but I'm not getting anywhere with it. Any ideas?>Also, any methods or ideas on how to approach creating code in general?do?>For example, what's the thought process for trying to do what I want to>I've tried pseudo code and it's helped some but then I hit the wall and__________________________________________________ _______________>don't how to go further. Thanks!
>
>_________________________________________________ ________________
>Frustrated with dial-up? Get high-speed for as low as $26.95.
>[url]https://broadband.msn.com[/url] (Prices may vary by service area.)
>
>
>--
>To unsubscribe, e-mail: [email]beginners-unsubscribe@perl.org[/email] For additional
>commands, e-mail: [email]beginners-help@perl.org[/email]
>
Send a QuickGreet with MSN Messenger
[url]http://www.msnmessenger-download.com/tracking/cdp_games[/url]
--
To unsubscribe, e-mail: [email]beginners-unsubscribe@perl.org[/email]
For additional commands, e-mail: [email]beginners-help@perl.org[/email]
Tim Johnson Guest
-
Charles K. Clarkson #3
RE: Counting (easy!) (YES!!)
Trent Rigsbee <sweetdaddysiki@hotmail.com> wrote:
:
: I think I figured it out! A FIRST!!
:
: for ($i = 1; $i <= 5; $i++){
: sleep 1;
: print "$i\n";
: }
As you move into larger programs and scripts it
is a good idea to always use strict and warnings.
use strict;
use warnings;
After adding these to the top of your script
you'll need to use 'my' before using most variables
for the first time:
use strict;
use warnings;
for ( my $i; $i <= 5; $i++ ) {
sleep 1;
print "$i\n";
}
You can also use the range operator to save some
typing:
for my $i ( 1 .. 5 ) {
sleep 1;
print "$i\n";
}
HTH,
Charles K. Clarkson
--
Head Bottle Washer,
Clarkson Energy Homes, Inc.
Mobile Home Specialists
254 968-8328
Charles K. Clarkson Guest



Reply With Quote

