Perl – How to get date of Previous wednesday from the given date without using DateTime


I want to find out the date of previous wednesday from the given date.

Eg. I have date as “20150804” and i would need “20150729”.

DateTime is not available and i cannot install it as well.

I looked at few examples but they were using DateTime.

Can you please redirect me where i can get some help.? Thanks.

I am planning to code something like below.



use warnings;
use strict;

my $dt="20150804";
my $prevWednesday=getPrevWednesday($dt);

sub getPrevWednesday()
    my $givenDt=shift;

Source: unix

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.