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: I don't think AllExcl is the issue. I think checking WebExcludeNodeProps maybe more relevant. But as you can see, DRM displays all by default. And you
  • Daniel: By default it displays all, I am not sure if you did something to exclude it. You may wish to test the WebBook system preference i.e. set a standard W
  • Daniel: Ganesh, doesn't sound like you are experienced with the product. Our company specializes in DRM and can help you with your implementation. Please cont

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.