Okay, I have some code where essentially I'm saying hello to a client and giving the current time. But about 20% of the time instead of printing $date it doesn't print anything. I put the following code in and I can't believe the results.
print "Forked child printing CMDSTART to client\n"; $date=`date`; print "\$date $date"; &S_print ("[$client_ipnum] $client_host $date connection attem +pt logged\n"); print "\$date $date"; &S_print ("This is a private server. All connections are logge +d\n"); &S_print ("username:\n"); print "sent username:\n";

S_print prints to the socket and print is just going to stdout. Here is the clip from stdout:
Forked child printing CMDSTART to client
$date $date sent username:
Not only does it look like it printed $date instead of it's value then it didn't print the next one and skipped ahead to print sent username. Then on the next run it worked okay:
Forked child printing CMDSTART to client
$date Thu Mar 13 00:25:32 CST 2003
$date Thu Mar 13 00:25:32 CST 2003
sent username:
un received: usernamex
pw received: start
Accepted connection
Am I going crazy? Can anyone make any sense out of this?

perl -v
This is perl, v5.8.0 built for i386-linux-thread-multi

In reply to $date in print is printing \$date ??? by drake50

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.