------------------------------------------------
On 28 Aug 2003 16:17:21 -0400, K Old <[EMAIL PROTECTED]> wrote:

> Hello everyone,
> 
> 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?

The one difference that I am aware of is the scoping. -w applies warnings to *all* 
code executed, whereas use warnings is file scoped (I believe) so that if you are 
working with a number of different modules that might cause warnings to be issued you 
will not see them under the 'use' method, but under -w you will.  I prefer this 
because it gives me more direct control, but as the other poster mentioned I am only 
dealing with 5.6.0 and newer interpreters these days...

> 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 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?
> 

Its actually buffering of the currently selected file handle which is usually STDOUT. 
Output is buffered until there is a "significant" amount so that the relatively 
expensive output process doesn't happen over and over. Though in most cases these days 
I doubt it has a "significant" negative performance impact.

Usually I leave things alone until I need them, but to each their own, and I think it 
is safe to assume Randal knows what he is doing :-).

http://danconia.org

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

Reply via email to