Closed p5pRT closed 16 years ago
$/ = "" should according to docs: "Setting to "" will treat two or more consecutive empty lines as a single empty line."
Works fine when write file out to disk and read it back in but fails with in memory files\, even though they should be equivalent.
Reproduce script: ========= BEGIN REPRODUCE SCRIPT ============= #!/usr/bin/perl -w =head1 perlbug.pl
This script demonstrates a perl bug - $/ = "" does not work properly for in-memory files.
=cut use strict; use Data::Dumper; use File::Temp qw(tempfile);
my $s = \<\<END; This is the contents of paragraph 1
This is the contents of paragraph 2
END
$/ = "";
my ($tmp\, $filename) = tempfile(); print $tmp $s; flush $tmp;
my $fh1; open($fh1\, "\<"\, $filename); my $o1 = scalar \<$fh1>;
my $fh2; open($fh2\, "\<"\, \$s); my $o2 = scalar \<$fh2>;
print Dumper [ $o1\, $o2]; ========= END REPRODUCE SCRIPT =============
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
simon.kissane@mq.edu.au (via RT) wrote:
[snip]
$/ = "" should according to docs: "Setting to "" will treat two or more consecutive empty lines as a single empty line."
Works fine when write file out to disk and read it back in but fails with in memory files\, even though they should be equivalent.
This looks to be fixed from 5.8.8
Reproduce script: ========= BEGIN REPRODUCE SCRIPT ============= #!/usr/bin/perl -w =head1 perlbug.pl
This script demonstrates a perl bug - $/ = "" does not work properly for in-memory files.
=cut use strict; use Data::Dumper; use File::Temp qw(tempfile);
my $s = \<\<END; This is the contents of paragraph 1
This is the contents of paragraph 2
END
$/ = "";
my ($tmp\, $filename) = tempfile(); print $tmp $s; flush $tmp;
my $fh1; open($fh1\, "\<"\, $filename); my $o1 = scalar \<$fh1>;
my $fh2; open($fh2\, "\<"\, \$s); my $o2 = scalar \<$fh2>;
print Dumper [ $o1\, $o2];
~/klad$ perl588 44833.pl $VAR1 = [ 'This is the contents of paragraph 1
'\, 'This is the contents of paragraph 1
' ];
HTH + Good luck\,
Abe - -- Merijn> We *do* need tests (I am not good in tests: hint hint)
Calling all happy passive readers of perl5-porters - submit a patch\, get your name into the AUTHORS file: fame\, immortality and more spam. -- Nicholas Clark on p5p @ 2004-01-22 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.7 (Darwin) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFGzF090u0nt7xxiCIRAsfhAJ0TgzYbV6Mf3/vRGVrcnQOhFnSbTACfZaHC 4tI7kCbm1rlnrzvt6yAa3WQ= =i4uX -----END PGP SIGNATURE-----
The RT System itself - Status changed from 'new' to 'open'
p5p@spam.wizbit.be - Status changed from 'open' to 'resolved'
Migrated from rt.perl.org#44833 (status was 'resolved')
Searchable as RT44833$