A solution using the, core since 5.10, Time::Piece module and its associated Time::Seconds for date arithmetic. I accept the strftime() default format for brevity but you could craft the output any way you like.

johngg@shiraz:~/perl/Monks$ perl -Mstrict -Mwarnings -MTime::Piece -MT +ime::Seconds -E ' my $ffJan = Time::Piece->strptime( q{2020/01/01}, q{%Y/%m/%d} ); $ffJan += ONE_DAY for 1 .. 5 - $ffJan->day_of_week(); my $end = Time::Piece->strptime( q{2020/06/01}, q{%Y/%m/%d} ); while ( $ffJan->epoch() < $end->epoch() ) { say $ffJan->strftime(); $ffJan += ONE_WEEK; }' Fri, 03 Jan 2020 00:00:00 UTC Fri, 10 Jan 2020 00:00:00 UTC Fri, 17 Jan 2020 00:00:00 UTC Fri, 24 Jan 2020 00:00:00 UTC Fri, 31 Jan 2020 00:00:00 UTC Fri, 07 Feb 2020 00:00:00 UTC Fri, 14 Feb 2020 00:00:00 UTC Fri, 21 Feb 2020 00:00:00 UTC Fri, 28 Feb 2020 00:00:00 UTC Fri, 06 Mar 2020 00:00:00 UTC Fri, 13 Mar 2020 00:00:00 UTC Fri, 20 Mar 2020 00:00:00 UTC Fri, 27 Mar 2020 00:00:00 UTC Fri, 03 Apr 2020 00:00:00 UTC Fri, 10 Apr 2020 00:00:00 UTC Fri, 17 Apr 2020 00:00:00 UTC Fri, 24 Apr 2020 00:00:00 UTC Fri, 01 May 2020 00:00:00 UTC Fri, 08 May 2020 00:00:00 UTC Fri, 15 May 2020 00:00:00 UTC Fri, 22 May 2020 00:00:00 UTC Fri, 29 May 2020 00:00:00 UTC

I hope this is helpful.

Update: It makes more sense to calculate the cut-off epoch once at the start rather than every loop.

johngg@shiraz:~/perl/Monks$ perl -Mstrict -Mwarnings -MTime::Piece -MT +ime::Seconds -E ' my $endEpoch = Time::Piece->strptime( q{2020/06/01}, q{%Y/%m/%d} )->ep +och(); my $ffJan = Time::Piece->strptime( q{2020/01/01}, q{%Y/%m/%d} ); $ffJan += ONE_DAY for 1 .. 5 - $ffJan->day_of_week(); while ( $ffJan->epoch() < $endEpoch ) { say $ffJan->strftime(); $ffJan += ONE_WEEK; }' Fri, 03 Jan 2020 00:00:00 UTC Fri, 10 Jan 2020 00:00:00 UTC Fri, 17 Jan 2020 00:00:00 UTC Fri, 24 Jan 2020 00:00:00 UTC Fri, 31 Jan 2020 00:00:00 UTC Fri, 07 Feb 2020 00:00:00 UTC Fri, 14 Feb 2020 00:00:00 UTC Fri, 21 Feb 2020 00:00:00 UTC Fri, 28 Feb 2020 00:00:00 UTC Fri, 06 Mar 2020 00:00:00 UTC Fri, 13 Mar 2020 00:00:00 UTC Fri, 20 Mar 2020 00:00:00 UTC Fri, 27 Mar 2020 00:00:00 UTC Fri, 03 Apr 2020 00:00:00 UTC Fri, 10 Apr 2020 00:00:00 UTC Fri, 17 Apr 2020 00:00:00 UTC Fri, 24 Apr 2020 00:00:00 UTC Fri, 01 May 2020 00:00:00 UTC Fri, 08 May 2020 00:00:00 UTC Fri, 15 May 2020 00:00:00 UTC Fri, 22 May 2020 00:00:00 UTC Fri, 29 May 2020 00:00:00 UTC

Cheers,

JohnGG


In reply to Re: Date::Manip ParseRecur help needed by johngg
in thread Date::Manip ParseRecur help needed by cormanaz

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.