title: Exactly 4 digits validation in perl
body: <p>I have a validation check when I pass the command line parameters to the perl program.I pass two years first passed argument should be lesser than the second passed argument and both the arguments should be only digits and also they should be exactly 4.</p>
  
  <p><code>#Sunny&gt;perl check.pl 2007 2008</code>  This is good</p>
  
  <p><code>#Sunny&gt;perl check.pl 2008 2007</code>  This is bad</p>
  
  <p><code>#Sunny&gt;perl check.pl 200 2007</code>  This is bad</p>
  
  <p>I have written code for this but not able to figure it out why its not working.</p>
  
  <pre><code>#!usr/bin/perl
  #check.pl
  
  if ($#ARGV &lt; 0) { }
  else
  {
    $fiscyear1 = $ARGV[0];
    $fiscyear2 = $ARGV[1];
  }
  
  if (($fiscyear1 !~ m/\d{4}/) and ($fiscyear2 !~ m/\d{4}/) and ($fiscyear1 &lt; $fiscyear2))
  { print "Bad parameters\n"; }
  else
  { print "good parameters\n"; }
  </code></pre>