I have a regex written like this and it works fine
output:
H:01
M:16
S:43
fs:.7
but I am now getting data in the format of
$data = '16:43.7';
and want
H:
M:16
S:43
fs:.7
or
$data = '43.7';
and want
H:
M:
S:43
fs:.7
I do not know how to make the regex conditional, I could always split it and hack something together but I'm always trying to learn
Thanks in advance.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Travis - Those who say it cannot be done are usually interrupted by someone else doing it; Give the wrong symptoms, get the wrong solutions;
Code:
$data = '01:16:43.7';
($cdr{dhour}, $cdr{dmin}, $cdr{dsec}, $cdr{dfsec}) = $data =~ /(.*):(.*):(.*)(\..*)/;
print "H:$cdr{dhour}\n";
print "M:$cdr{dmin}\n";
print "S:$cdr{dsec}\n";
print "fs:$cdr{dfsec}\n";
H:01
M:16
S:43
fs:.7
but I am now getting data in the format of
$data = '16:43.7';
and want
H:
M:16
S:43
fs:.7
or
$data = '43.7';
and want
H:
M:
S:43
fs:.7
I do not know how to make the regex conditional, I could always split it and hack something together but I'm always trying to learn
Thanks in advance.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Travis - Those who say it cannot be done are usually interrupted by someone else doing it; Give the wrong symptoms, get the wrong solutions;