Hello,

I have a perl script that is distributed with my application. The script is
run on many platforms including Unix, Linux and Windows 9x/NT.

Currently the script determines if a string is a number in the following
way:

if (! /^(\-?\d+\.?\d*|\-?\.\d+)$/)
{
  # Not a number (or contains commas)
  :
}
else
{
  # Is a number (could have decimal point character)
  :
}

This is similar to the Perl Cookbook's recommendation in section 2.1 on page
44.

The problem is that this application is also distributed to customers in
countries that use the comma as the decimal point character.

I have read a bit about use locale, perllocale and setlocale (I do not claim
to really understand what I have read) and have not yet found a general way
that would allow me to write this script once and have it work for whatever
locale happens to be current on the machine that is running this script. In
other words, a function like

if (!IsNumberUsingCurrentLocale ($string))
{
:

is what I looking for. This function would run on Unix, Linux and Windows
9x/NT.

Otherwise, I can ask the application user to specify the decimal point
character the script should use. Seems like this kind of stuff could be
provided by perl or a perl module?

Any suggestions?

Thank you in advance for your help.

Richard

_______________________________________________
ActivePerl mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/activeperl

Reply via email to