Hello,

$refTime = "01:22:33,456"; #as in your example
$refTime =~ /(\d+):(\d+):(\d+),(\d+)/; #capture the elements and assign
$hours = $1;
$minutes = $2;
$secs = $3;
$mili = $4;

or much simpler:

my($hours, $minutes, $secs, $mili) = $ref_time =~ m{(\d+)}g;

Note that if it doesn't match then the variable will be undef...

This doesn't look strict or wanrings safe either, please always use

 use strict;
 use warnings;

Please buy Perl best Practices, you'll love it and your code will be much more readable (like $ref_time vs $refTime is clearer and less problem prone...)

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to