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

  • Home
  • SEARCH
  • 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 6241517
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T11:46:55+00:00 2026-05-24T11:46:55+00:00

Is there a perl routine that I can utilize that would do the following?

  • 0

Is there a perl routine that I can utilize that would do the following? I’m looking for a good example.

I want to be able to print out a list of days based on a range.

As a parameter I want to be able to do something like:
./myperlscript -r 20110630 20110731 (as an example where -r = range).

So basically, if I can put (2) dates in this format as inputs and print me those days.

20110630
20110701
20110702
...
..
  • 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-24T11:46:55+00:00Added an answer on May 24, 2026 at 11:46 am

    This should get you started. You probably want to add some input validation (ie making sure that the elements of @ARGV are formatted correctly and that the first represents a date smaller than the second, etc, etc…).

    use strict;
    use warnings;
    use DateTime;
    
    unless(@ARGV==2)
    {
        print "Usage: myperlscript first_date last_date\n";
        exit(1);
    }
    
    my ($first_date,$last_date)=@ARGV;
    
    my $date=DateTime->new(
    {
      year=>substr($first_date,0,4),
      month=>substr($first_date,4,2),
      day=>substr($first_date,6,2)
    });
    
    
    while($date->ymd('') le $last_date)
    {
      print $date->ymd('') . "\n";
      $date->add(days=>1);
    }
    

    ETA: In case it isn’t clear what’s going on, we create $date as a DateTime object, parsing the year, month, and day that were given in $first_date. Then, we keep printing out the year, month, and day without separators ($date->ymd('')) and increase $date by one day until we’re at $last_date.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Are there any good (and preferably free) code coverage tools out there for Perl?
Are there any free Perl IDEs out there for Windows that have debugging capabilities,
I'm sure there's some trivial one-liner with perl, ruby, bash whatever that would let
I have a Perl routine that manages error checking. There are about 10 different
Is there a module or Perl code that extract n-grams of words from a
Is there any Perl script to read multiple PDF files and get the number
There's been a cluster of Perl-hate on Stack Overflow lately, so I thought I'd
Is there an elegant way in Perl to find the newest file in a
Are there conventions for function names when using the Perl Test::More or Test::Simple modules?
Is there any way to listen to an Oracle AQ using a Perl process

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.