# NOTES: 
# The initial line 
# my @res = $filecontents =~ m/
# is required exactly (minus the comment character of course)
#
# Your pattern must also have exactly two capture groups, one for the context and one for the match.
# If you need to do extra grouping in your pattern, use the non-capturing syntax "(?: )".
#
# We are running the pattern over the entire file at once, not line-by-line. We assign
# the results in an array context, and we've used the /g modifier, so the pattern matches 
# repeatedly as many times as possible until the file content is exhausted. We've used two
# separate capture groups, so @res contains sequential tuples of the context around the match, and
# the match itself, i.e. (context1, match1, context2, match2, [...]). Whew.

@res = $filecontents =~ m/
(			# Begin backref group for string surrounding match
  .{0,20}		# grab 20 characters before the word "temperature"
  temperature		# the literal word temperature
  \D{0,50}		# up to 50 non-digit characters
    (			# start group to capture number
      (?:		# start non-capturing group to allow repeating nnn,nnn,nnn
        \d+		# one or more digits
        [\.\,]?		# followed by an optional . or ,
        \d+		# followed by one or more digits
      )+		# close non-capturing group, "+" allows repeating nnn,nnn,nnn.nnn
    )			# close capture group for number, grabbed as backref $2
  \D\D			# two consective non-digit characters (end the number match)
  .{0,20}		# grab 20 more characters after the number
)			# end the backref group for the surrounding text
/xigs;			# x=allow wrapping & comments
			# i=case insensitive	 
 	 		# g=repeat match over and over until no more matches
  			# s=allow . to match newline

# This line is necessary since this file is inserted into the main script via "do".
1;
