From: miker Date: Thu, 3 Mar 2005 16:02:37 +0000 (+0000) Subject: fixed numeric opperators X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=e4b813d7b89062a926ff494332b8f7d8ccb70eb7;p=opensrf%2Fbjwebb.git fixed numeric opperators git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@161 9efc2488-bf62-4759-914b-345cdb29e865 --- diff --git a/src/perlmods/JSON.pm b/src/perlmods/JSON.pm index cbdbc3e..1b86899 100644 --- a/src/perlmods/JSON.pm +++ b/src/perlmods/JSON.pm @@ -5,7 +5,14 @@ sub new { return bless \$x => __PACKAGE__; } use overload ( '""' => \&toString ); -use overload ( '0+' => sub { ${$_[0]} } ); +use overload ( '0+' => sub { $_[0]->toString } ); +use overload ( '+' => sub { int($_[0]) + int($_[1]) } ); +use overload ( '-' => sub { int($_[0]) - int($_[1]) } ); +use overload ( '*' => sub { int($_[0]) * int($_[1]) } ); +use overload ( '/' => sub { int($_[0]) / int($_[1]) } ); +use overload ( '%' => sub { int($_[0]) % int($_[1]) } ); +use overload ( '**' => sub { int($_[0]) ** int($_[1]) } ); +use overload ( 'neg' => sub { neg(int($_[0])) } ); sub toString { defined($_[1]) ? ${$_[1]} : ${$_[0]} }