string and time question

Discussion in 'Perl Misc' started by a, Aug 15, 2006.

  1. a

    a Guest

    Hi,
    Have two questions.
    1> Let say,
    my $str = "abcd";
    How can I do the following,
    $str = $str + 1 make $str becomes "abce"?

    2> Is it possible to do the following?
    for(k=1;k<9;k++){
    do something
    wait for 10second
    }

    Thanks
    a, Aug 15, 2006
    #1
    1. Advertising

  2. a

    Simon Taylor Guest

    Simon Taylor, Aug 15, 2006
    #2
    1. Advertising

  3. a

    Simon Taylor Guest

    Hello again 'a'

    > 2> Is it possible to do the following?
    > for(k=1;k<9;k++){
    > do something
    > wait for 10second
    > }



    Try

    perldoc -f sleep

    ie:

    for (my $k=1;$k<9;$k++){
    print 'doing something' . "\n";
    sleep 10;
    }

    or using the '..' range operator:

    for (1..8) {
    print 'doing something' . "\n";
    sleep 10;
    }


    - Simon Taylor
    --
    http://www.perlmeme.org
    Simon Taylor, Aug 15, 2006
    #3
  4. a wrote:
    > 1> Let say,
    > my $str = "abcd";
    > How can I do the following,
    > $str = $str + 1 make $str becomes "abce"?


    Auto-increment works on strings jsut fine:

    $str++

    > 2> Is it possible to do the following?
    > for(k=1;k<9;k++){
    > do something
    > wait for 10second
    > }


    Sure:

    for my $k (1..9){
    do something;
    sleep 10;
    }

    jue
    Jürgen Exner, Aug 15, 2006
    #4
  5. a

    -berlin.de Guest

    Jürgen Exner <> wrote in comp.lang.perl.misc:

    > Auto-increment works on strings jsut fine:

    ^^^^ <-----+
    |
    |
    Hey! ----------------------------+

    Anno
    -berlin.de, Aug 16, 2006
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. engsol
    Replies:
    2
    Views:
    948
    Dan Bishop
    Jan 26, 2004
  2. Replies:
    8
    Views:
    477
    Magnus Lycka
    Aug 5, 2005
  3. flamesrock
    Replies:
    8
    Views:
    452
    Hendrik van Rooyen
    Nov 24, 2006
  4. Replies:
    1
    Views:
    798
    Paul Boddie
    Mar 11, 2007
  5. David Joseph Bonnici
    Replies:
    1
    Views:
    212
    Gunnar Hjalmarsson
    May 15, 2005
Loading...

Share This Page