in reply to Re(4): shebang line
in thread shebang line

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