dmm writes: "I believe, however, that Perl itself may, upon detecting a shebang line in an included file, honor at least the -w and -T switches, if present."

After running some tests, I found that this is true when perl is run from the command line, such as this:

% perl file.pl

In this case, the interpreter does enable the -w and -T switches if they are present on the shebang line in the file passed to perl. However, this does not appear to be the case for imported files.

Here's what I did:

First, I created a file like this:

#!/usr/bin/perl

require "o.pl";

exit 0;
Next, I create the o.pl file:

#!/usr/bin/perl -w

print "y $s\n";

1;

When running the first file, no warning is printed. However, if you enable the -w switch on the shebang line of the first file, then the following warning will be returned:

Use of uninitialized value in concatenation (.) or string at o.pl line 3.
y

Further, if you remove the -w switch from the shebang line in o.pl and from the main script, and instead use the warnings pragma in o.pl, the warning will be returned.

Like this:
#!/usr/bin/perl

use warnings;

print "y $s\n";

1;

I used perl 5.6.1 for testing.

Thanks again!

-perlmongrel

Imagination is the one weapon in the war against reality. -- Jules de Gaultier


In reply to Re: Re(4): shebang line by perlmongrel
in thread shebang line by perlmongrel

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.