-
Notifications
You must be signed in to change notification settings - Fork 577
can't dup DATA? #369
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
From @vlbrownIf I do this #!/usr/bin/perl open (INPUT,"<&STDIN"); it works. I can type input and INPUT is a dup of STDIN. the while loop but if I try open (INPUT,"<&DATA"); __END__ when I run this, nothing is printed. Can I not dup DATA? Is this because it Can Perl be changed to allow dup'ing of the DATA filehandle? Perl Info
|
From [Unknown Contact. See original ticket]
VB> Can Perl be changed to allow dup'ing of the DATA filehandle? Would you realy want to allow that? Since the start of DATA is Interesting open(INPUT, "<&3") doesn't work either. (The 3 is from <chaim> |
From @mjdominusIndeed, if the data after the __END__ tag is long enough, then Vicki's |
From @vlbrownAt 15:07 -0400 8/11/99, Chaim Frenkel wrote:
Yes. :-) Rationale (from the MacPerl mailing list):
I do this too. It's often easier to fake the data after the I was a tad surprised that DATA didn't seem to be duplicatable [sic] this
Well, I figure that if someone told Perl to allow it, they'd tell Perl
As usual, I could live with a change to the docs explaining why this cannot |
From [Unknown Contact. See original ticket]Graham Barr <gbarr@pobox.com> writes:
This is perfectly normal "dup'ing a stdio buffered handle" issue. open(FOO,__FILE__); will have same problem. The DATA handle has been read so stdio has slurped (say) 8K of data into If you fix it for DATA you should/will fix it for all handles ... -- |
From @gbarrThis is a bug that needs to be fixed because open(INPUT,"<&" . fileno(DATA)) or die "$!"; __END__ will print nothing and the following does exactly what you want. seek(DATA,0,1); __END__ This is probably a bug that needs fixing. On Wed, Aug 11, 1999 at 01:07:29PM -0700, Vicki Brown wrote:
-- |
From @mjdominusBarr says:
Patch enclosed. Someone with more experience should look at it and #!/usr/bin/perl Idea of patch: Call `seek' automatically to flush the buffer just --- doio.c 1999/06/10 23:11:05 1.1 # -print "1..6\n"; print "ok 1\n"; @@ -37,3 +37,16 @@ print STDOUT "ok 6\n"; |
From @vlbrownAt 15:31 -0400 8/11/99, Mark-Jason Dominus wrote:
Gaah! You're right. I see "long enough" as being 16297 characters in MacPerl (5.004), 1147 I'm leaning toward bug :) |
From @mjdominus
I forgot to do perldelta. --- pod/perldelta.pod 1999/08/11 19:58:16 1.3 +=head2 Buffered data discarded from input filehandle when dup'ed. =over 4 |
From [Unknown Contact. See original ticket]
It's always been annoying that this doesn't work correctly: % perl whateverscript "<&DATA" on <ARGV> handling. --tom |
From @mjdominus
My patch fixes that. |
From @jhiThe patch doesn't seem to work in Digital UNIX, the new io/dup subtest This is what print "in1 = '$in1', out1 = '$out1', in2 = '$in2', out2 = '$out2'\n"; outputs after the subtest #7. in1 = 'Line 1 My guess is that calling PerlIO_seek(fp, 0, SEEK_CUR) doesn't flush. PerlIO_flush(fp); instead of the seek()? -- |
From @mjdominus
Yeah.
No good reason; I think I had seek on the brain because of Graham's Thanks. |
From @jhiMark-Jason Dominus writes:
I tried it already. It works.
No need to resubmit the patch; just confirm whether it works for you
-- |
From @jhiNick Ing-Simmons writes:
But neither does seek(), it seems. Shall we do do both? And if -- |
From [Unknown Contact. See original ticket]Jarkko Hietaniemi <jhi@iki.fi> writes:
Because where PerlIO is stdio fflush() may not do anything useful -- |
From @jhiNick Ing-Simmons writes:
Okay, *now* I want an updated patch... -- |
From [Unknown Contact. See original ticket]Jarkko Hietaniemi <jhi@iki.fi> writes:
An understandable optimization - if stdio is not bothered about dups.
My only concern is that some stdio somewhere will complain about
Perhaps the correct fix is : Although that perhaps should be getpos/setpos to handle REC files -- |
From @jhiIt seems that PerlIO_seek() doesn't flush in IRIX 6.5, either. -- |
Migrated from rt.perl.org#1204 (status was 'resolved')
Searchable as RT1204$
The text was updated successfully, but these errors were encountered: