summaryrefslogtreecommitdiff
path: root/ext/B/O.pm
diff options
context:
space:
mode:
authorRobin Houston <robin@cpan.org>2001-04-22 23:14:50 +0100
committerJarkko Hietaniemi <jhi@iki.fi>2001-04-22 20:52:13 +0000
commit34a48b4b2c642540b102169c8b78c89beeebe902 (patch)
treebcde612a187996a009c228c063d02201dd1da2b5 /ext/B/O.pm
parent6f36ad4ab3b6497d1280576be438eea8cce4348e (diff)
downloadperl-34a48b4b2c642540b102169c8b78c89beeebe902.tar.gz
Support BEGIN blocks in B::Deparse (& more)
Message-ID: <20010422221450.A18921@puffinry.freeserve.co.uk> p4raw-id: //depot/perl@9781
Diffstat (limited to 'ext/B/O.pm')
-rw-r--r--ext/B/O.pm27
1 files changed, 25 insertions, 2 deletions
diff --git a/ext/B/O.pm b/ext/B/O.pm
index 338d8030c0..89352fb6e7 100644
--- a/ext/B/O.pm
+++ b/ext/B/O.pm
@@ -3,7 +3,16 @@ use B qw(minus_c save_BEGINs);
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;
@@ -11,6 +20,11 @@ sub import {
}
CHECK {
+ if ($quiet) {
+ close STDOUT;
+ open (STDOUT, ">&SAVEOUT");
+ close SAVEOUT;
+ }
use B::].$backend.q[ ();
if ($@) {
croak "use of backend $backend failed: $@";
@@ -38,12 +52,21 @@ O - Generic interface to Perl Compiler backends
=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