in reply to Re: Find out, if "use warnings(all)" and "use strict(all)" are used
in thread Find out, if "use warnings(all)" and "use strict(all)" are used

Thanks, that was a good hint. I tried to read the warning and strict bits from other packages, so I've to find a way to do it without explicit BEGIN blocks. The following thing works, but why ?!?
package Aa; use warnings; #no warnings 'void'; use strict; #no strict 'refs'; package Bb; #>> when you uncomment this, it wont work!! #use strict; #use warnings; #<< my $strict = eval('package Aa;my $h;BEGIN { $h = ${^H} };return $h;'); printf "use strict " . ($strict == 1794 ? 'yes' : 'no') . "\n"; my $warn = eval('package Aa;my $w;BEGIN { $w = ${^WARNING_BITS} };retu +rn $w;'); printf "use warnings " . (unpack('b*', warnings::bits('all')) == unpac +k('b*', $warn) ? 'yes' : 'no') . "\n";
This prints:
use strict = yes
use warnings = yes
till you use all-warnings ans all-stricts. Conclusion: it works fine and do what I want.

And by the way: in last few weeks I've see a lot of little perl wonders like this. I think, there must be a perl-good. Now I'm a believer :D

  • Comment on Re^2: Find out, if "use warnings(all)" and "use strict(all)" are used
  • Download Code