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

All,

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.

Code:

#!/opt/perl-5.8.0/bin/perl

use warnings;
use strict;

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

sub getPrevWednesday()
{
    my $givenDt=shift;
    ...
}


Source: unix

Leave a Reply