For the first part, you are to develop a regular expression to
recognize floating point numbers of the form described here. I would
recommend doing this in a piece by piece fashion using scalar
variables to store different subexpressions of the final regular
expression. Store your Perl script in float.plx.
For our purposes, a floating point number consists of
The decimal part consists of
The exponent part consists of
The following are examples of floating point numbers that would be matched based on the above rules:
6.35 -3.6 +5.4 5.0e1 2.5E+2 4.4e-10 0.5
The following are examples of substrings that would not be matched based on the above rules:
abc 3-e6 5+.5 6 5. .5 5e1Take note of the last four. Integers should not be matched. And while the last 3 are valid in most programming languages, the rules given above exclude them to simplify things slightly.