|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now! |
|
#1
|
|||
|
|||
|
Can someone give me an example of using sigalarm and alarm to print a smiple message at an interval, like every 5 seconds? I am having trouble getting this to work.
Second, would such a process run in the background? Or would it take the focus? |
|
#2
|
|||
|
|||
|
Code:
print "Tell me something....\n";
eval
{
$SIG{ALRM} = sub { die "Timeout"; };
alarm 10;
$input = <STDIN>;
alarm 0;
}
if($@ && $@ =~ /Timeout/) {
print "You didn't tell me anything!\n";
} else {
print "You said: " . $input;
}
You should be able to figure it out from my example here. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Perl Programming > Alarm |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|