#!/bin/perl use warnings; use strict; my $currentYear = `date +%Y`; chomp($currentYear); my $currentMonth = `date +%m`; chomp($currentMonth); my $currentDay = `date +%d`; chomp($currentDay); my $currentHour = `date +%H`; chomp ($currentHour); my $tempDay; if ($currentHour < 10 ) { $tempDay = $currentDay - 1; print "temp: $tempDay\n"; if ($tempDay =~ m/(\d\d)$/ ) { $tempDay = $tempDay; } elsif ($tempDay =~ m/(\d)$/) { $tempDay = '0'.$tempDay; } else { print "Unable to match day\n"; } } my $directoryDay = $tempDay; my $dir = 'something/something/'.$currentYear.'/'.$currentMonth.'/'.$directoryDay; print "\n"; print "month: $currentMonth\n"; print "day : $currentDay\n"; print "dir : $dir\n\n";