<?xml version="1.0" encoding="windows-1252"?>
<node id="695167" title="Re: shebang arguments" created="2008-07-02 14:14:25" updated="2008-07-02 10:14:25">
<type id="11">
note</type>
<author id="139958">
friedo</author>
<data>
<field name="doctext">
&lt;p&gt;They're similar, but not exactly the same. Putting &lt;c&gt;-w&lt;/c&gt; in the command line (or the shebang) will turn on warnings globally, for all the Perl code loaded by that process.&lt;/p&gt; 
&lt;p&gt;On the other hand, &lt;c&gt;use warnings&lt;/c&gt; is a "lexical pragma," and only applies in the block in which it's used. If you put it at the top of a script or module, then it will apply for that entire file (this is called file scope.) Inside a block, it applies only for that block:
&lt;c&gt;
#!/usr/bin/perl

print "no warnings out here!" . $undef_var;
{
    use warnings;  # now warnings are turned on
    print "this will warn" . $undef_var;
}

# now warnings are off again.
&lt;/c&gt;
&lt;p&gt;(Note: Try running that with and without &lt;c&gt;-w&lt;/c&gt; to see the difference.&lt;/p&gt;
&lt;p&gt;
Typically, it's a good idea to &lt;c&gt;use warnings&lt;/c&gt; in your file scope, which allows you to occasionally turn them off in small blocks (using &lt;c&gt;no warnings&lt;/c&gt;) if you absolutely must do something that will generate a warning. See [doc://perllexwarn] for the gory details.
&lt;/p&gt;
&lt;i&gt;And what are things like the '-w' called (eg the -f or -d to specify file or directory)?&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;
Those are called command-line switches or arguments, and perl's are all documented in [doc://perlrun].
&lt;/p&gt;</field>
<field name="root_node">
695165</field>
<field name="parent_node">
695165</field>
</data>
</node>
