September 17, 2014
 
 
RSSRSS feed

More Special Variables in Perl: Outputs

Keep It Moving

  • December 7, 2009
  • By Juliet Kemp

Juliet Kemp
After looking last week at at special Perl variables for reading things in, here are some that may be useful when you want to write things out.

$| If this is set to a non-zero value, it forces an immediate buffer flush, and then a flush after every write or print. The default is zero, which means some buffering is done. If you're writing to a file, you're not likely to be too worried about this, but if you're writing to a pipe or a socket, you may want to be sure your output doesn't wait around.

$, This variable sets what print outputs between the elements that are passed in to it. By default it's undefined. So, this code:

print "1", "2", "3", "n";
{
        local $, = " ";
        print "1", "2", "3", "n";
}
will output...

Read the rest of this article at ServerWatch.

Sitemap | Contact Us