Ok. I think I have gotten to the heart of it. And like other things of this ilk, it looks to me like a bug or misfeature.
I would have thought this would work:
package B::Syntax; sub compile { return sub { $O::BEGIN_output =~ /Syntax OK/ ? exit 0 : exit 1; } }; 1;
And then call with:
# $prog_or_e_option = ... ; system("perl -MO=-qq,Syntax $prog_or_e_option"); # Test $?
Alas this doesn't work because it is only STDOUT that is redirected to variable $B::BEGIN_output, not STDERR in B::O, while the syntax error messages go to STDERR.
I guess I will have to seek guidance from perl5-porters.
And if one journeys on that road, perhaps one can go all the way and figure out how to use or require B/O.pm inside Perl.
In reply to Re^5: How to do perl -c inside perl?
by rockyb
in thread How to do perl -c inside perl?
by rockyb
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |