in reply to (tye)Re2: Debugger, use strict, use warnings
in thread Debugger, use strict, use warnings

My bad. I was thinking of vars. For pragmas you have to be a little creative. But if you use what I learned at Re (tilly) 1: How does strict work?, it is doable but slightly tricky.

Perhaps an example would be best.

Suppose that you wanted a version of strict and vars wrapped up in one, takes one argument list and splits it in the obvious way between strict and vars...

package my_strict; use strict; use vars; sub import { shift; # I know my class name I hope my (@vars, @strictures); foreach (@_) { if (/\W/) { push @vars, $_; } else { push @strictures, $_; } } my $pkg = caller; $^H = eval " package $pkg; no strict; use strict qw(@strictures); vars->import(\@vars); \$^H; "; } 1;
Is that what you wanted?

Replies are listed 'Best First'.
(tye)Re3: Debugger, use strict, use warnings
by tye (Sage) on Apr 10, 2001 at 22:55 UTC

    After playing with this for a while, it boils down to the fact that you can't get the pragma to bubble up an extra level but you can cut'n'paste (varying amounts of) code from the pragma's *.pm file into your own *.pm in order to create your own custom pragma which does the same thing (which seems obvious now but sure didn't a few minutes ago).

    Anyway, the e.pm I wanted above can be had rather simply as:

    package e; require strict; require warnings; sub import { &strict::import; &warnings::import; } 1;

            - tye (but my friends call me "Tye")