Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6147153
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T19:03:50+00:00 2026-05-23T19:03:50+00:00

I have a validation check when I pass the command line parameters to the

  • 0

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.

#Sunny>perl check.pl 2007 2008 This is good

#Sunny>perl check.pl 2008 2007 This is bad

#Sunny>perl check.pl 200 2007 This is bad

I have written code for this but not able to figure it out why its not working.

#!usr/bin/perl
#check.pl

if ($#ARGV < 0) { }
else
{
  $fiscyear1 = $ARGV[0];
  $fiscyear2 = $ARGV[1];
}

if (($fiscyear1 !~ m/\d{4}/) and ($fiscyear2 !~ m/\d{4}/) and ($fiscyear1 < $fiscyear2))
{ print "Bad parameters\n"; }
else
{ print "good parameters\n"; }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T19:03:50+00:00Added an answer on May 23, 2026 at 7:03 pm

    This sounds like a bad case of overthinking things…

    What you want is to verify that the arguments are two years, in the form YYYY, and that the second year comes after the first.

    Well, 9999 would pass any digit check, but it is hardly a valid year. Same with 0101, or 3021, etc.

    What you want is to set a given range, and make sure the arguments are numeric.

    use strict;
    use warnings;
    
    my $yr1 = shift;
    my $yr2 = shift || usage();
    
    usage() unless $yr1 =~ /^\d+$/;
    usage() unless $yr2 =~ /^\d+$/;
    
    my $min_year = 1900;
    my $max_year = 2200;
    
    if ( ($yr1 < $min_year) or ($yr1 > $max_year) ) {
        die "Invalid year: $yr1";
    }
    if ( ($yr2 < $min_year) or ($yr2 > $max_year) ) {
        die "Invalid year: $yr2";
    }
    if ( $yr1 >= $yr2 ) {
        die "Invalid sequence: $yr2 is not greater than $yr1";
    }
    
    sub usage {
        die "Usage script.pl <year1> <year2>";
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Form validation for check boxes only seems to be working in IE....? Anyone have
I have two validation groups: parent and child I have an add button that
I have some validation code which should display the max / min of a
I have two testing questions. Both are probably easily answered. The first is that
Ok, I have a validation script that checks everything on the form - but
I recently inherited a VBA macro that needs to have validation logic added to
I have a validation control that has the following expression: (?=(.*\\d.*){2,})(?=(.*\\w.*){2,})(?=(.*\\W.*){1,}).{8,} That's a password
i have a validation in my .net textbox where it will take only numbers
i have a validation in my .net textbox where it will take only numbers
I have a validation function I'm using inside of codeigniter. function valid_image() { if

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.