in reply to $date in print is printing \$date ???

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;

  • Comment on Re: $date in print is printing \$date ???

Replies are listed 'Best First'.
Re: Re: $date in print is printing \$date ???
by drake50 (Pilgrim) on Mar 13, 2003 at 08:12 UTC
    You're exactly right. I misread the two $dates. So now the only mistery is why the `date` isn't returning anything.