Merge branch '1056-pandora-wux-grid-server' into 'develop'

Added to_number to Tools.pm

See merge request !787
This commit is contained in:
vgilc 2017-09-06 12:37:10 +02:00
commit da5a060f7e
1 changed files with 21 additions and 0 deletions

View File

@ -80,6 +80,7 @@ our @EXPORT = qw(
sqlWrap
is_numeric
is_metaconsole
to_number
clean_blank
pandora_sendmail
pandora_trash_ascii
@ -1471,6 +1472,26 @@ sub is_metaconsole ($) {
return 0;
}
###############################################################################
# Check if a given variable contents a number
###############################################################################
sub to_number($) {
my $n = shift;
if ($n =~ /[\d+,]*\d+\.\d+/) {
# American notation
$n =~ s/,//g;
}
elsif ($n =~ /[\d+\.]*\d+,\d+/) {
# Spanish notation
$n =~ s/\.//g;
$n =~ s/,/./g;
}
if(looks_like_number($n)) {
return $n;
}
return undef;
}
#######################
# ENCODE
#######################