I have developed a perl script to dynamically build an html page from a supplied text file.
On my RedHat Linux box it works perfectly yet on my ISPs FreeBSD box I have a problem. All I want to do is return the day of the week for a given date (not always today's date)
On RedHat Linux:
$dw = "25/12/1999";
$DofW = `date --date "$dw" +%w`;
... works perfectly and $DofW contains 6 indicating a Saturday. (It took me a while to figure out I needed double quotes around $dw)
On my ISPs box, I find from the man page for date, that the above date command doesn't work the same. I need to call it like this:
$DofW = `date -v25d -v12m -v1999y \"+%u\"`;
The problems occur when I replace the 25, 12 and 1999 with variables.
I /split/ the required date into @Date then assign......
$Day = $Date;
$Month = $Date;
$Year = $Date;
# I then try the following 4 lines.....
$TD = "date -v".$Day."d -v".$Month."m -v".$Year."y \"+%u\"";
$DofW1 = `$TD`;
$DofW2 = `"$TD"`;
$DofW3 = `date -v25d -v12m -v1999y \"+%u\"`;
# Printing out the 4 values into html I get:
$TD : date -v 25d -v12m -v1999y:
$DofW3 :6 :
(The colons ':' are mine to indicate boundaries)
So why does my manual $DofW3 work (Returning 6 for a Saturday) yet the other two don't?