develooper Front page | perl.perl5.porters | Postings from August 2008

Re: [perl #57762] opening in memory fails

Thread Previous
From:
Bram
Date:
August 10, 2008 08:37
Subject:
Re: [perl #57762] opening in memory fails
Message ID:
20080810173724.4xewxmj1ckkc4o00@horde.wizbit.be
Citeren "arekm@carme-pld.pld-linux.org (via RT)" <perlbug-followup@perl.org>:

> code is:
> my $data = \'';
> open my $file, '>', $data or die "error: $!";
>
> on perl 5.10.0:
> $ LC_ALL=C perl a.pl
> error: Invalid argument at a.pl line 2.
> (fails)
>
> on perl 5.8.8:
> $ perl a.pl
> $
> (no problem)
>
> [Please do not change anything below this line]
> -----------------------------------------------------------------

This was changed with Change 28798.

http://public.activestate.com/cgi-bin/perlbrowse/p/28798
Change 28798 by rgs@stencil on 2006/09/07 11:45:36

	Fix for [perl #40267] PerlIO::scalar doesn't respect readonly-ness

----Program----
my $data = \'';
open my $file, '>', $data or die "error: $!";

----Output of .../p53cBQG/perl-5.9.4@28797/bin/perl----

----EOF ($?='0')----
----Output of .../p8lplba/perl-5.9.4@28798/bin/perl----
error: Invalid argument at rt-57762.pl line 2.

----EOF ($?='5632')----


The behaviour in perl-5.8.8 is incorrect and the behaviour in  
perl-5.10.0 is correct.

Note how:

#!/usr/bin/perl -l

my $data = \'';
$$data = "a";

Produces:
Modification of a read-only value attempted at rt-57762.pl line 4.


If you can't modify $$data then open my $file, '>', $data  shouldn't  
modify it either.


Kind regards,

Bram



Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About