develooper Front page | perl.perl5.porters | Postings from December 2001

[PATCH B::Deparse] __DATA__ and packages

Thread Next
From:
Rafael Garcia-Suarez
Date:
December 21, 2001 15:00
Subject:
[PATCH B::Deparse] __DATA__ and packages
Message ID:
20011222000129.A713@rafael
This patch fixes a bug regarding deparsing of __DATA__ by B::Deparse.
More precisely, now this program :
	package Foo;
	print while <DATA>;
	__DATA__
	abc
deparses correctly.


--- ext/B/B/Deparse.pm.orig	Thu Dec 20 22:59:47 2001
+++ ext/B/B/Deparse.pm	Fri Dec 21 23:45:32 2001
@@ -561,9 +561,11 @@
 
 	# Print __DATA__ section, if necessary
 	no strict 'refs';
-	if (defined *{$self->{'curstash'}."::DATA"}{IO}) {
+	my $laststash = defined $self->{'curcop'}
+	    ? $self->{'curcop'}->stash->NAME : $self->{'curstash'};
+	if (defined *{$laststash."::DATA"}{IO}) {
 	    print "__DATA__\n";
-	    print readline(*{$self->{'curstash'}."::DATA"});
+	    print readline(*{$laststash."::DATA"});
 	}
     }
 }

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About