This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
__DATA__ and packages
[perl5.git] / ext / B / B / Deparse.pm
index 7bf95df..778cec7 100644 (file)
@@ -561,9 +561,11 @@ sub compile {
 
        # 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"});
        }
     }
 }