Oracle DRM Blog

02 Jul, 2009

Perl Tip on check value for numeric or non-numeric

Posted by: Daniel In: Perl

This is a little tip on Perl for those interested. Perl does not distinguish variables between text or numbers. And so when you’re manipulating data or input, you need to be careful and make your own checks first. It may seem simple but also can be way more complicated. For example, what if you have a string that combines numbers at the beginning and string at the end? What if the number is more like an IP address than a real number? What if you have negatives? Here’s a few lines of code you can use to determine the various checks you can do using regular expressions:

if (/\D/) { print “has nondigits\n” }
if (/^\d+$/) { print “is a whole number\n” }
if (/^-?\d+$/) { print “is an integer\n” }
if (/^[+-]?\d+$/) { print “is a +/- integer\n” }
if (/^-?\d+\.?\d*$/) { print “is a real number\n” }
if (/^-?(?:\d+(?:\.\d*)?|\.\d+)$/) { print “is a decimal number\n” }
if (/^([+-]?)(?=\d|\.\d)\d*(\.\d*)?([Ee]([+-]?\d+))?$/) { print “a C float\n” }

Enjoy the week guys!

Visitors who read this post, also read:



No Responses to "Perl Tip on check value for numeric or non-numeric"

Comment Form


  • Daniel: Naren, depending on the system version you are using, before v11 you are likely to use HAL to integrate DRM into HFM. In v11 you use ODI.
  • Daniel: Kalyan, yes DRM can manage any hierarchy beyond Oracle because it does not have pre-build interfaces. It exports to database or text format that can w
  • Kalyan: Hi Daniel, I am looking for some info on DRM.Can you please help. 1. Can DRM manage the hierarchies of non-Oracle products. (For example, does i

About This Blog

My name is Daniel Poon. I am a multi-disciplined business intelligence professional with a strong dynamic career leading Financial Processes, People, BI Systems and Global Projects to accomplishments. Known for passion in implementing process excellence, quality BI solutions and creative innovations. Thanks for visiting my special interest blog.

 Subscribe This Blog For Free Now

Disclaimer: The words, ideas and opinions here are my own. Please don't assume they represent the opinion of my employer, any other person or organization. Do read the Terms of Use. If you would like to quote me, please ask me first or provide a link back.