in reply to Re^4: How to do perl -c inside perl?
in thread How to do perl -c inside perl?
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^6: How to do perl -c inside perl?
by rockyb (Scribe) on Aug 29, 2012 at 06:51 UTC | |
by rockyb (Scribe) on Aug 31, 2012 at 01:58 UTC |