in reply to Closing and re-opening the DATA Filehandle
Ugly hack:
producesmy $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
which is what you asked for but needs some serious encapsulation work at least. - tye (but my friends call me "Tye")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.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: (tye)Re: Closing and re-opening the DATA Filehandle
by Adam (Vicar) on Apr 05, 2001 at 01:21 UTC | |
by tye (Sage) on Apr 05, 2001 at 18:37 UTC |
In Section
Seekers of Perl Wisdom