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: You need to check the console for more details of the messages. The process manager doesn't start usually is because of the app server setup or not ab
  • Daniel: You rpobably have not configured the Windows components yet.
  • Daniel: No it won't cause memory problem. I can't imagine your hierarchy will be in gigabytes size... You can install everything in one machine but I guess be

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.