Not only does it look like it printed $date instead of it's value
Not quite. You have two statements that read
print "\$date $date";
In those cases where $date contains the output from date (including trailing newline!), the output will look like
$date Thu ...
$date Thu ...
When date fails, $date is empty and the output of the two prints is glued together:
$date $date
As to why date fails I don't know, and since you are not checking the return codes of the system call, you don't know also ;-).
I suggest that in this case, don't use date at all. Check out localtime, it should do what you want
Update: If you're printing the output to a log file, use gmtime instead. Example:
print scalar localtime;
print scalar gmtime;
In reply to Re: $date in print is printing \$date ???
by crenz
in thread $date in print is printing \$date ???
by drake50
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |