<?xml version="1.0" encoding="windows-1252"?>
<node id="255780" title="Re: Checking for single digit" created="2003-05-05 21:14:27" updated="2005-06-08 09:42:20">
<type id="11">
note</type>
<author id="132645">
vladb</author>
<data>
<field name="doctext">
In your match try to use the special regexp anchors &lt;code&gt;^ and $&lt;/code&gt;:
&lt;code&gt;
  if ($input =~ /^[0-9]$/) {
    print "input was a single digit number\n";
  } else {
    print "input wasn't a single digit number\n";
  }
&lt;/code&gt;
&lt;br&gt;
From the Perl regular expression tutorial (&lt;a href="http://www.perldoc.com/perl5.8.0/pod/perlre.html"&gt;perlre&lt;/a&gt;), the "^" and "$" are defined as:
&lt;code&gt;
^   Match the beginning of the line
$   Match the end of the line (or before newline at the end)
&lt;/code&gt;
Unless they are used, Perl will look for a match anywhere within your &lt;code&gt;$input&lt;/code&gt; string! ;-)
&lt;br&gt;&lt;br&gt;
&lt;b&gt;Update:&lt;/b&gt; threw in some perldoc definitions for your viewing pleasure :)
&lt;br&gt;&lt;br&gt;
_____________________

&lt;code&gt;
# Under Construction
&lt;/code&gt;</field>
<field name="root_node">
255779</field>
<field name="parent_node">
255779</field>
</data>
</node>
