in reply to scope of "use strict"? (needed: "superstrict")
I don't fully understand why you would want to force modules to be compiled under strictures when they weren't designed to do so. As others have pointed out, this has the potential of generating lots of errors, and many of them will point to perfectly legitimate code, since it's possible to create bug-free code that isn't strict-compliant.
But I thought it sounded like a fun little challenge, so in the spirit of "give them what they ask for" here is a little snippet that will test-compile every module in the dependancy heirarchy of your script with strictures enforced:
use strict; use warnings; use IO::CaptureOutput qw/capture_exec/; my( $stdout, $stderr ) = capture_exec( 'perl', '-d:Modlist=nocore,stop,path,noversion', $ARGV[0] ); my( @modules ) = split /\n/, $stderr; foreach my $module ( @modules ) { my( $stdout, $stderr ) = capture_exec( 'perl', '-Mstrict', '-c', $module ); print "Module: $module\n\tSTDOUT = $stdout\n\tSTDERR = $stderr\n"; }
This snippet requires Devel::Modlist, and IO::CaptureOutput. They aren't core, so you'll probably have to install them. Then run it like this:
perl stricttester.pl yourcode.pl >output.log
Then examine what you get in output.log. Every module that is strictures-compliant, and that is otherwise free from compiletime problems will compile "ok", and every module that isn't will give you a bunch of error messages.
It actually works really slick.
Enjoy!
Dave
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: scope of "use strict"? (needed: "superstrict")
by argv (Pilgrim) on Jul 07, 2005 at 05:31 UTC | |
Re^2: scope of "use strict"? (needed: "superstrict")
by Anonymous Monk on Jul 07, 2005 at 07:41 UTC | |
Re^2: scope of "use strict"? (needed: "superstrict")
by leriksen (Curate) on Jul 07, 2005 at 12:41 UTC |