good chemistry is complicated, and a little bit messy -LW |
|
PerlMonks |
File::Slurp bug? Should I bother?by chester (Hermit) |
on Sep 07, 2005 at 15:26 UTC ( [id://489891]=perlquestion: print w/replies, xml ) | Need Help?? |
chester has asked for the wisdom of the Perl Monks concerning the following question:
Hello monks, I was using File::Slurp and I noticed newlines were constantly being added to the end of every line after multiple reads/writes of the same file. The module appears (to me) to be buggy in Windows.
file:
output:
I undef $/ here because it's the only thing I could think to try; File::Slurp mentions using it in passing, but it doesn't help. Putting the "normal" version in its own block and using local on $/ has the same result. I haven't tested this in Linux, but the difference between line terminators in Windows and Linux (and everything else) strikes me as a possible source of error here. Two questions: 1) Can anyone confirm this behavior? Is it normal? I know Perl6 will have slurp; is there some nuance to slurp which causes this to be expected behavior? 2) Is it worth bothering to use a module to slurp files (in Perl5)? It's as simple as local-izing $/ and reading into a scalar. If I'm really feeling lazy I can throw it into my own slurp sub. Will Perl6's slurp have any more to offer?
Back to
Seekers of Perl Wisdom
|
|