Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

Re: Re: What the [sub]in 'L value do they have?

by BrowserUk (Pope)
on Dec 16, 2002 at 02:02 UTC ( #220100=note: print w/replies, xml ) Need Help??

in reply to Re: What the [sub]in 'L value do they have?
in thread What the [sub]in 'L value do they have?

Given the way :lvalue works now, I came to the same conclusion, but then I set about trying to understand what uses it did have, procedural code or otherwise and I came up empty. For a good, practical use anyway, but the documentation is sparse to put it mildy, which is why I decided to move my questions and thoughts away from the original thread.

The fact that I can modify the original entity directly through an lvalue sub may be an optimisation, but I don't see substr($foo, 3, 2) = 'fred'; as intrinsically different from substr($foo, 3, 2, 'fred'); I had never thought of doing nor encountered anything that did:

$s = "the quick brown fox"; substr($s, 4, 5) =~ s/ick/iet/; print $s; the quiet brown fox

And that does have some interesting possibilities and is exactly the sort answer I was looking for. I'd like to see a real use for it and the benefits thereof described, but in the absence, you've given me a new way to look at a facility of perl that I long been intrigued by but have singularly failed to find a good use for.

That said, I still like the syntactic possibility of lvalue assignment for mutators and the only thing stopping that is the exposure of information that the compiler/interpreter has available to it. As I can see at least two ways of making that information available that would not affect its current usage in anyway, and would not break any existing code, I wonder if this would be such a hard thing to do and what objections there could be to doing it?

Like many features of perl, noone would be forced to use it, but it would give those that would like to (Ie. ME:^) another way to do things.

Examine what is said, not who speaks.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://220100]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (4)
As of 2017-07-26 03:52 GMT
Find Nodes?
    Voting Booth?
    I came, I saw, I ...

    Results (383 votes). Check out past polls.