[Opensrf-commits] r1229 - trunk/src/perlmods/OpenSRF/Utils

svn at svn.open-ils.org svn at svn.open-ils.org
Wed Jan 30 12:58:13 EST 2008


Author: miker
Date: 2008-01-30 12:30:43 -0500 (Wed, 30 Jan 2008)
New Revision: 1229

Modified:
   trunk/src/perlmods/OpenSRF/Utils/SettingsParser.pm
Log:
turn \d{1,10} into a number on the wire

Modified: trunk/src/perlmods/OpenSRF/Utils/SettingsParser.pm
===================================================================
--- trunk/src/perlmods/OpenSRF/Utils/SettingsParser.pm	2008-01-30 17:06:21 UTC (rev 1228)
+++ trunk/src/perlmods/OpenSRF/Utils/SettingsParser.pm	2008-01-30 17:30:43 UTC (rev 1229)
@@ -92,6 +92,11 @@
 	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 @@
 
 	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');



More information about the opensrf-commits mailing list