dpuu has asked for the wisdom of the Perl Monks concerning the following question:
I have a file that we're including via C<do>. I've has a request to impose strictness and warnings on that file. Warnings are easy ($^W); but stricness is more difficult.
I could obviously slurp the file into a string and prepend a "use strict;" declaration before eval-ing it. I'd have to fix-up the filename in any error messages ("eval 347" is not a very meaningful), but it would be do-able.
The other way I can think of is to do the same prepending, but do it by messing with the filename passed to C<do>:
This doesn't seem ideal, either. Is there a simpler way?do qq(cat $filename | perl -ple 'BEGIN { print "use strict;" }');
--Dave
Opinions my own; statements of fact may be in error.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: imposing "strict" on an included file
by gaal (Parson) on Jul 22, 2004 at 22:22 UTC | |
by simonm (Vicar) on Jul 23, 2004 at 17:01 UTC | |
Re: imposing "strict" on an included file
by BUU (Prior) on Jul 22, 2004 at 23:58 UTC | |
by dpuu (Chaplain) on Jul 23, 2004 at 17:53 UTC | |
by BUU (Prior) on Jul 23, 2004 at 21:07 UTC | |
by dpuu (Chaplain) on Jul 23, 2004 at 23:31 UTC | |
Re: imposing "strict" on an included file
by pg (Canon) on Jul 22, 2004 at 21:48 UTC |
Back to
Seekers of Perl Wisdom