Perl validating numbers

Rated 3.89/5 based on 705 customer reviews

@list = qw(5 4.4 0 -1.2 asdf 12asdf asdf12 1.2e3 0e0); foreach $thing (@list) Note that ("12asdf" * 1) equals 12...

Also note that the above example does NOT work for numbers in scientific notation.

# zero or one letter \s* # optional trailing whitespace (just in case) $ # end of string Actually, NIN doesn't allow D, F, I, Q, U or V for the first two letters and doesn't allow O for the second letter; on top of this, the prefix letters can not be BG, GB, NK, KN, TN, NT and ZZ.

Also the suffix letter is either A, B, C or D, but may be represented by a space if unknown.

perl validating numbers-86

perl validating numbers-67

perl validating numbers-25

perl validating numbers-74

For something as fundamental as this it really should be.

Also, you may want to check out the other posts in the series.

The comments in the code will make more sense if you have seen the other examples. /usr/bin/perl # Functions in Perl are called subroutines.

Edit: Andrew Bauer modified my answer to add checks for allowed/disallowed characters that were unknown at the time I answered.

You should up-vote his answer since it is more complete and apparently performs better validation.

Leave a Reply

  1. cuckold dating hotwife 08-Apr-2020 02:46

    “Give the press-release version of you,” says Kate Wachs, Ph.