Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

comment on

( [id://3333] : superdoc . print w/replies, xml ) Need Help??
UPDATE: This is my 100th post! :))

Yes, but think about buffering. Perl won't flush it's buffer until it sees a newline.
You have no \n after the <br>, so this is what happens:
  1. perl fills the buffer
  2. perl sleeps for two seconds
  3. perl appends to the buffer, and then flushes it because the end of the script is reached.
Which of course is not what you want.

You could put a \n after the <br>, or turn on the autoflush using $| = 1 (often seen obfuscated as $|++).

print "First<br>\n"; sleep 2 print "Second\n"; ### $| = 1; print "First<br>"; sleep 2; print "Second";


I recommend the newline solution, because HTML doesn't care about the newline being there, and autoflushing decreases performance.

Information about $| and many other special variables can be found in perlvar.

2;0 juerd@ouranos:~$ perl -e'undef christmas' Segmentation fault 2;139 juerd@ouranos:~$


In reply to Re: Re: Re: A delay effect... by Juerd
in thread A delay effect... by kiat

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.