-
Notifications
You must be signed in to change notification settings - Fork 560
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
scalar filehandle and truncate/seek #16008
Comments
From cm.perl@abtela.comWhile writing tests for a rollback mechanism, I chanced on a limitation [cm@cos7 ~/perl]$ rm -f tmp.dat a very similar code fails on a scalar filehandle : [cm@cos7 ~/perl]$ ../localperl/bin/perl5.25.9 -e 'open my $h, ">>", (in the latter case the impact of the open mode on the behavior of seek This is apparently a long-standing limitation (it gets a mention e.g. in As limitations go however, it is a weird one. Any chance that it might Thanks in advance, --Christian Flags: Site configuration information for perl 5.25.9: Configured by cm at Fri Jun 9 09:44:55 CEST 2017. Summary of my perl5 (revision 5 version 25 subversion 9) configuration: @INC for perl 5.25.9: Environment for perl 5.25.9: |
From @jkeenanOn Fri, 09 Jun 2017 14:01:49 GMT, cm.perl@abtela.com wrote:
Can you clarify what the intent of $x is?
Likewise.
Likewise.
Likewise.
Thank you very much. |
The RT System itself - Status changed from 'new' to 'open' |
From @jkeenanOn Fri, 09 Jun 2017 17:46:35 GMT, jkeenan wrote:
(Please ignore the two subsequent "Likewise". I was having trouble reading the code as one-liner.) -- |
From @jkeenanOn Fri, 09 Jun 2017 14:01:49 GMT, cm.perl@abtela.com wrote:
The file attached demonstrates that the problem exists independently of the use of the IO::Handle notation for the 'truncate' and 'seek' calls. Thank you very much. -- |
From cm.perl@abtela.comLe 09/06/2017 à 20:07, James E Keenan via RT a écrit :
Indeed, and thank you for looking at this (sorry for the extraneous FWIW, opening in read-write mode does not help either : [cm@cos7 ~/perl]$ export PS2= |
From cm.perl@abtela.comLe 12/06/2017 à 14:36, Christian Millour a écrit :
an additional twist on this is that if I comment out the call to [cm@cos7 ~/perl]$ ../localperl/bin/perl5.25.9 -e ' It looks like the call to seek is simply ignored in append mode (">>"), This does not appear to be documented. Any clue anyone ? |
From @tonycozOn Fri, 09 Jun 2017 07:01:49 -0700, cm.perl@abtela.com wrote:
There's no perlio entry point for truncating a file, so the perl truncate implementation directly uses the ftruncate() function (and fails in this case) There's also no stat() entry point, so C<< -s $fh >> also doesn't work.
The behaviour of append mode looks like the intended behaviour: output is always appended at end of file. This mirrors the behaviour of an "a" mode for fopen: a Open for appending (writing at end of file). The file is cre‐ a+ Open for reading and appending (writing at end of file). The It could be better documented.
It should be possible to implement by adding a truncate entry to PerlIO_funcs (perliol.h) Tony |
From cm.perl@abtela.comLe 14/06/2017 à 03:19, Tony Cook via RT a écrit :
Thank you. It appears I had wrong expectations wrt append mode. Indeed, Opening a file with append mode (a as the first character in the e.g. Debian 7.7 : Opening a file in append mode (a as the first character of mode) Which means that the only way to change the contents of a file in append [cm@cos7
A worthwhile endeavor by any means ;-) I take it then that there is no hope of being able to fix the problem
|
Migrated from rt.perl.org#131544 (status was 'open')
Searchable as RT131544$
The text was updated successfully, but these errors were encountered: