@@ -129,6 +129,9 @@ sub StartOB {
129
129
if ( scalar @{$self -> {OutputBuffers }} == 0 ) {
130
130
$| = 1; # flush contents of STDOUT
131
131
open ( $self -> {RootSTDOUT }, " >&STDOUT" ) or die $! ; # dup filehandle
132
+ # $self->{RootSTDOUT} = $fh;
133
+ # undef $fh;
134
+ # say STDERR "stdout in startob ", Dumper($self->{RootSTDOUT});
132
135
}
133
136
unshift ( @{$self -> {OutputBuffers }}, [ $mode , " " , $lineno ] );
134
137
close ( STDOUT ); # must be closed before redirecting it to a variable
@@ -617,19 +620,19 @@ sub OutputResult {
617
620
my $contents_ref = shift ; # reference
618
621
my $fname = shift ; # "" or other false value => STDOUT
619
622
my $proc ;
620
- my $out_fd ;
623
+ my $out_fh ;
621
624
622
625
for $proc ( @{$self -> {Postprocessors }} ) {
623
626
&$proc ( $contents_ref );
624
627
}
625
628
626
629
if ( $fname ) {
627
- open ( $out_fd , " >" , $fname ) or die $! ;
630
+ open ( $out_fh , " >" , $fname ) or die $! ;
628
631
} else {
629
- open ( $out_fd , " >&STDOUT" ) or die $! ;
632
+ open ( $out_fh , " >&STDOUT" ) or die $! ;
630
633
}
631
- print $out_fd $$contents_ref ;
632
- close ( $out_fd ) or die $! ;
634
+ print $out_fh $$contents_ref ;
635
+ close ( $out_fh ) or die $! ;
633
636
} # OutputResult()
634
637
635
638
# === Command line parsing ================================================
@@ -744,14 +747,14 @@ sub Main {
744
747
my $self = shift or die (" Please use Text::PerlPP->new()->Main" );
745
748
746
749
my $lrArgv = shift // [];
747
- say STDERR " \n ## -----------------\n ## argv:\n " ,
748
- (Dumper($lrArgv ) =~ s / ^/ ## / mgr );
749
- say STDERR " self " , Dumper($self );
750
+ # say STDERR "\n## -----------------\n## argv:\n",
751
+ # (Dumper($lrArgv) =~ s/^/## /mgr);
752
+ # say STDERR "self ", Dumper($self);
750
753
unless (_parse_command_line( $lrArgv , $self -> {Opts } )) {
751
754
return EXIT_OK; # TODO report param err vs. proc err?
752
755
}
753
756
754
- say STDERR " ## opts:\n " , (Dumper($self -> {Opts }) =~ s / ^/ ## / mgr );
757
+ # say STDERR "## opts:\n", (Dumper($self->{Opts}) =~ s/^/## /mgr);
755
758
756
759
if ($self -> {Opts }-> {PRINT_VERSION }) {
757
760
print " PerlPP version $Text::PerlPP::VERSION \n " ;
@@ -836,9 +839,9 @@ sub Main {
836
839
}
837
840
keys %{$self -> {Opts }-> {SETS }};
838
841
839
- say STDERR " \n # Defs_RE: $self ->{Defs_RE}" ;
840
- say STDERR " # Defs_repl_text:\n " , (Dumper($self -> {Defs_repl_text })=~s / ^/ # / gmr );
841
- say STDERR " # Sets\n " , (Dumper($self -> {Sets })=~s / ^/ # / gmr );
842
+ # say STDERR "\n# Defs_RE: $self->{Defs_RE}";
843
+ # say STDERR "# Defs_repl_text:\n", (Dumper($self->{Defs_repl_text})=~s/^/# /gmr);
844
+ # say STDERR "# Sets\n", (Dumper($self->{Sets})=~s/^/# /gmr);
842
845
# Make the copy for runtime
843
846
emit " my %S = (\n " ;
844
847
for my $defname (keys %{$self -> {Opts }-> {SETS }}) {
@@ -860,9 +863,9 @@ sub Main {
860
863
}
861
864
862
865
# The input file
863
- ProcessFile( $self -> {Opts }-> {INPUT_FILENAME } );
866
+ $self -> ProcessFile( $self -> {Opts }-> {INPUT_FILENAME } );
864
867
865
- my $script = EndOB(); # The generated Perl script
868
+ my $script = $self -> EndOB(); # The generated Perl script
866
869
867
870
# --- Run it ---
868
871
if ( $self -> {Opts }-> {DEBUG } ) {
@@ -880,7 +883,7 @@ sub Main {
880
883
print STDERR $result ;
881
884
return EXIT_PROC_ERR;
882
885
} else { # Save successful output
883
- OutputResult( \EndOB(), $self -> {Opts }-> {OUTPUT_FILENAME } );
886
+ $self -> OutputResult( \( $self -> EndOB() ), $self -> {Opts }-> {OUTPUT_FILENAME } );
884
887
}
885
888
}
886
889
return EXIT_OK;
0 commit comments