ambuli
asked on
Perl: How to identify a line with hex fields in it
Hi there,
I have a file with some lines printed in the following way.This is a timestamp
a name at 71050.762 s [04562b0c]
I have to find this lines and then extract the time value, i.e 71050.762 s in this example. Please note that spaces as in the line.
Thank you.
I have a file with some lines printed in the following way.This is a timestamp
a name at 71050.762 s [04562b0c]
I have to find this lines and then extract the time value, i.e 71050.762 s in this example. Please note that spaces as in the line.
Thank you.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
sorry! I think your code does it.
Thanks.
Thanks.
$time=$1 if /([\d.]+) s \[\w+\]/;
will check if a line is in the form /([\d.]+) s \[\w+\] before extracting the time.
If you want to be more specific you might use
$time=$1 if /^a name at ([\d.]+) s \[04562b0c\]$/;
will check if a line is in the form /([\d.]+) s \[\w+\] before extracting the time.
If you want to be more specific you might use
$time=$1 if /^a name at ([\d.]+) s \[04562b0c\]$/;
ASKER
Thank you
ASKER
How can I check if a particular line is in this form before extracting the time.