Counting (easy!) (YES!!)

Ask a Question related to PERL Beginners, Design and Development.

  1. #1

    Default 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

  2. Similar Questions and Discussions

    1. 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...
    2. 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++) {...
    3. 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...
    4. 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...
    5. 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?
  3. #2

    Default 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 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]


    --
    To unsubscribe, e-mail: [email]beginners-unsubscribe@perl.org[/email]
    For additional commands, e-mail: [email]beginners-help@perl.org[/email]

    Tim Johnson Guest

  4. #3

    Default 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

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139