Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > string and time question

Reply
Thread Tools

string and time question

 
 
a
Guest
Posts: n/a
 
      08-15-2006
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


 
Reply With Quote
 
 
 
 
Simon Taylor
Guest
Posts: n/a
 
      08-15-2006
a wrote:
> Hi,
> Have two questions.
> 1> Let say,
> my $str = "abcd";
> How can I do the following,
> $str = $str + 1 make $str becomes "abce"?


The auto-increment operator ++ will do this for you.

See the "Auto-increment and Auto-decrement" section in perldoc perlop
or online at:


http://perldoc.perl.org/perlop.html#...o-decrement---

- Simon Taylor
--
http://www.perlmeme.org
 
Reply With Quote
 
 
 
 
Simon Taylor
Guest
Posts: n/a
 
      08-15-2006
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.. {
print 'doing something' . "\n";
sleep 10;
}


- Simon Taylor
--
http://www.perlmeme.org
 
Reply With Quote
 
Jürgen Exner
Guest
Posts: n/a
 
      08-15-2006
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


 
Reply With Quote
 
anno4000@radom.zrz.tu-berlin.de
Guest
Posts: n/a
 
      08-16-2006
Jürgen Exner <> wrote in comp.lang.perl.misc:

> Auto-increment works on strings jsut fine:

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

Anno
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
convert time string in UTC to time in local time davelist@mac.com Python 1 03-11-2007 12:57 AM
Is time.time() < time.time() always true? flamesrock Python 8 11-24-2006 06:51 AM
GMT time to local time, according to timezone and summer/winter time. David Joseph Bonnici Perl Misc 1 05-15-2005 09:15 PM
String.replaceAll(String regex, String replacement) question Mladen Adamovic Java 3 12-05-2003 04:20 PM
Re: String.replaceAll(String regex, String replacement) question Mladen Adamovic Java 0 12-04-2003 04:40 PM



Advertisments
 



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