From 146cce77233c424cce438ef3ed2c30f397719835 Mon Sep 17 00:00:00 2001 From: miker Date: Wed, 30 Jan 2008 17:30:43 +0000 Subject: [PATCH] turn \d{1,10} into a number on the wire git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@1229 9efc2488-bf62-4759-914b-345cdb29e865 --- src/perlmods/OpenSRF/Utils/SettingsParser.pm | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/perlmods/OpenSRF/Utils/SettingsParser.pm b/src/perlmods/OpenSRF/Utils/SettingsParser.pm index 5e280e0..ac36dca 100755 --- a/src/perlmods/OpenSRF/Utils/SettingsParser.pm +++ b/src/perlmods/OpenSRF/Utils/SettingsParser.pm @@ -92,6 +92,11 @@ sub merge_perl { return $base; } +sub _check_for_int { + my $value = shift; + return 0+$value if ($value =~ /^\d{1,10}$/o); + return $value; +} sub XML2perl { my $node = shift; @@ -101,12 +106,12 @@ sub XML2perl { for my $attr ( ($node->attributes()) ) { next unless($attr); - $output{$attr->nodeName} = $attr->value; + $output{$attr->nodeName} = _check_for_int($attr->value); } my @kids = $node->childNodes; if (@kids == 1 && $kids[0]->nodeType == 3) { - return $kids[0]->textContent; + return _check_for_int($kids[0]->textContent); } else { for my $kid ( @kids ) { next if ($kid->nodeName eq 'comment'); -- 2.11.0