The Other1 wrote:
> Hi John,

Hello,

> Thank you so much for the code you posted, it works great and is pretty
> elegant.  If you have a second, could you explain this line to me?
> 
>     if ( $row->[ $column ] =~ /^[\d.+-]+$/ ) {
> 
> And this one as well:
>     if ( $column =~ /^[\d.+-]+$/ ) {

Because you have two types of data, floating point and time, that ensures that
only floating point (contains digits or decimal point or plus sign or minus
sign) is used in the calculation for the average.

> I think these check to see if the line begins with (^) a number (\d) or
> more (.) , one or more of preceding (+), but I am not sure why it is
> followed by -  Then the next +$/
> is match previous and end of line?

The regular expression /^[\d.+-]+$/ anchors the character class [\d.+-]+ to
the beginning and end of the string so that the string will match if it only
contains the characters in the class.  The character class matches one or more
of the characters '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '.', '+'
or '-'.  For a better regular expression to match floating point numbers see
the FAQ:

perldoc -q "scalar is a number"




John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to