I love Smart::Comments, use it a bunch. I got greedy and wanted to simply switch it on and off using a variable/optin whatnot.
Thing is , it's a 'source filter'- it does stuff to your code that changes the behaviour- pre compile. Very witty. So.. the following does not work:
#!/usr/bin/perl -w use strict; use Smart::Comments '###'; use Getopt::Std; my $o = {}; getopts('d', $o); ### smart comments are on unless ($o->{d}) { print STDERR 'debug is not on. no smart comments..'; no Smart::Comments; } ### i'd like this to output if -d is used
But of course every comment after no Smart::Comments; will not be parsed to output.
I tried an eval of 'no Smart::Comments' - but that must run before the whole script is compiled- so ... no cigar. I tried some variations of eval and require too.
I also tried a wasteful pre compile to set Smart::Comments to on- but it won't fly through to the rest of the script.
Any suggestions? This is mainly curiosity- seems like an interesting problem. Would there be a way to programmatically (that's a word?) turn off or on a source filter to the same calling source?- ach- head hurts :-)
For: | Use: | ||
& | & | ||
< | < | ||
> | > | ||
[ | [ | ||
] | ] |