use Carp;
sub import {
- my ($class, $backend, @options) = @_;
+ my ($class, @options) = @_;
+ my $quiet = 0;
+ if ($options[0] eq '-q') {
+ $quiet = 1;
+ shift @options;
+ open (SAVEOUT, ">&STDOUT");
+ close STDOUT;
+ open (STDOUT, ">", \$O::BEGIN_output);
+ }
+ my $backend = shift (@options);
eval q[
BEGIN {
minus_c;
}
CHECK {
+ if ($quiet) {
+ close STDOUT;
+ open (STDOUT, ">&SAVEOUT");
+ close SAVEOUT;
+ }
use B::].$backend.q[ ();
if ($@) {
croak "use of backend $backend failed: $@";
=head1 SYNOPSIS
- perl -MO=Backend[,OPTIONS] foo.pl
+ perl -MO=[-q,]Backend[,OPTIONS] foo.pl
=head1 DESCRIPTION
This is the module that is used as a frontend to the Perl Compiler.
+If you pass the C<-q> option to the module, then the STDOUT
+filehandle will be redirected into the variable C<$O::BEGIN_output>
+during compilation. This has the effect that any output printed
+to STDOUT by BEGIN blocks or use'd modules will be stored in this
+variable rather than printed. It's useful with those backends which
+produce output themselves (C<Deparse>, C<Concise> etc), so that
+their output is not confused with that generated by the code
+being compiled.
+
=head1 CONVENTIONS
Most compiler backends use the following conventions: OPTIONS