develooper Front page | perl.perl5.porters | Postings from October 2014

Re: [perl #122947] [EXPERIMENT] Lvalue references

Thread Previous | Thread Next
From:
Salvador Ortiz Garcia
Date:
October 14, 2014 17:39
Subject:
Re: [perl #122947] [EXPERIMENT] Lvalue references
Message ID:
543D5FB8.6050803@msg.com.mx
On 10/14/2014 10:06 AM, H.Merijn Brand wrote:
> On Tue, 14 Oct 2014 15:43:40 +0100, "Paul \"LeoNerd\" Evans"
> <leonerd@leonerd.org.uk> wrote:
>
>> On Tue, 14 Oct 2014 08:47:15 -0400
>> Ricardo Signes <perl.p5p@rjbs.manxome.org> wrote:
>>
>>> Also, we have LVALUE refs.  Is this feature actually
>>> related to that?
>> The things we have that are called LVALUE are the lvalues returned by
>> the substr() function so that mutations of it can affect the original:
>>
>>    my $str = "Hello world";
>>    substr( $str, 0, 5 ) = "Goodbye";   <== assignment to an LVALUE
> is that (internally) different from using the 4-arg form (which I
> prefer because it is much faster)?
If you use the lvalue returned only once, no. But:

$ perl -E 'my $str = "Hello"; for(substr($str,1,1)) { say $_; $_="ee"; 
say $str; $_ = "aaa"; say $str }'

e
Heello
Haaallo

---
sortiz


Thread Previous | Thread Next


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