string and time question

A

a

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
 
S

Simon Taylor

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
 
J

Jürgen Exner

a said:
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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top