I know that the /x modifier is part of the recommended best practices, but I nonetheless think that adding spaces within a regular expression does not help readability when spaces are part of what you want to match in the string.

I would write the relevant line as follows:

Code

my $temperature2 = $1 if $odb =~ /Temperature\s+\d+\s+(\d+)/;

Or even:

Code

my $temperature2 = $1 if $odb =~ /Temperature +\d+ +(\d+)/;

BTW, all these regexes will fail if the temperature values may contain a decimal point. If such is the case, change "\d" to a character class such as [\d.], as in the following example:

My regular expression was not intended to be a great solution. It was intended to emphasize the concept of match every field and return the one of interest. I felt that the unnecessary whitespace helped make that point. "Best Practice" requires matching whitespace explicitly. From that viewpoint, It would have been better had I used \s+ rather than \D+.

Many of our readers would find a true "Best Practice" solution to be obscure. You seem to have a good compromise. Good Luck, Bill