Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: RFC: List of first day of each month

by hippo (Bishop)
on Jan 31, 2020 at 16:27 UTC ( [id://11112191]=note: print w/replies, xml ) Need Help??


in reply to RFC: List of first day of each month

TIMTOWTDI, of course. A slightly different approach, still with Time::Piece but adding a month at a go. It's shorter and (to me) a little clearer.

#!/usr/bin/env perl use strict; use warnings; use Time::Piece '1.32'; my $date = localtime->add_years (-4)->truncate (to => 'year'); my $end_date = localtime; while ($date <= $end_date) { print "$date\n"; $date = $date->add_months (1); }

There's nothing wrong with your method AFAICS.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11112191]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (3)
As of 2024-04-20 04:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found