in reply to Re^4: how to loop
in thread how to loop
something like this would be more prudent:# Interval to change at if we want $mode = "running" my $interval = $ARGV[0]; # Change the mode if we have been passed an interval $mode = "running" if ($interval);
That makes sure that you don't try to do arithmetic on a non-numeric string, or sleep for a negative number of seconds.my $interval = 0; if ( @ARGV ) { ( $interval ) = ( $ARGV[0] =~ /(\d+)/ ) or die "Usage: $0 [m]\n m: number of minutes between color cha +nges\n"; } $mode = "running" if ( $interval );
(update -- minor nit-pick -- since you now have an "interval" variable that is either true or false, you don't really need a "mode" variable, do you?)
|
|---|