Ugly hack:
my $pos= tell(DATA);
chomp( my $x= <DATA> );
warn "Testing($x)";
{
my $fh= do { local(*FH); \*FH };
open $fh, "<&DATA" or die "Can't save DATA: $!\n";
close DATA or warn "Can't close DATA: $!\n";
open DATA, "<&=".fileno($fh) or die "Can't restore DATA: $!\n";
seek DATA, $pos, 0 or die "Can't reposition DATA: $!\n";
}
warn "Testing";
chomp( $x= <DATA> );
warn "Testing($x)";
__END__
some data
produces
Testing(some data) at redata.pl line 4, <DATA> line 1.
Testing at redata.pl line 12.
Testing(some data) at redata.pl line 14, <DATA> line 1.
which is what you asked for but needs some serious encapsulation work at least.
-
tye
(but my friends call me "Tye")