K Old wrote:
> 
> Hello everyone,

Hello,

> Having been a Perl programmer for several years now I have become
> accustom to using the following as my normal "start" of any Perl script:
> 
> #!/usr/bin/perl
> use warnings;
> use strict;
> 
> Randal Schwartz uses this:
> 
>     #!/usr/bin/perl -w
>     use strict;
>     $|++;
> 
> Is there any difference between the -w and "use warnings" declaration?
> I know that both turn on warnings and the -w is commonly used at the
> command line, but was just curious as to if one was "better" than the other.

The warnings pragma was added to Perl5 to allow lexical scoping of warnings
and allow finer control over which warnings to use/not use.

#!Perl4

LOOP: {
    local $^W;  # turn off ALL warnings
    # do something that will produce a warning message
    }

#!Perl5

LOOP: {
    no warnings 'numeric';
    # do something that will produce a 'numeric' warning message
    }


perldoc perllexwarn


> The posting a few weeks ago about "for" vs. "foreach" was interesting and got
> me thinking about warnings.
> 
> One other item, Randal uses $|++; to "turn off the buffering for STDOUT".
> What exactly is buffering of standard output?

It doesn't turn off buffering, it effects whether the currently selected file
handle will autoflush its output.

#!/usr/bin/perl
$|++;  # turn on autoflush for the currently selected filehandle (STDOUT).

select STDERR;  # select a different filehandle

$| = 1;  # turn on autoflush for the currently selected filehandle (STDERR).



John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to