Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

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

by Chmrr (Vicar)
on Dec 15, 2002 at 08:37 UTC ( #219978=note: print w/replies, xml ) Need Help??

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

The only time I used : lvalue was in writing the following subroutine:

sub set : lvalue { @_ == 1 ? $_[0] : set($_[0]{$_[1]},@_[2..$#_]); }

..which is used to set values at any depth in a recursive hash structure, like so:

use Data::Dumper; sub set : lvalue { @_ == 1 ? $_[0] : set($_[0]{$_[1]},@_[2..$#_]); } my $h = {foo => 1, bar => 2, baz => { troz => 3, zort => 4, poit => { qux => 5, quux => 6, }, }, }; print Dumper($h); set($h, qw/baz troz/) = 42; set($h, qw/baz poit qux/) = 17; print Dumper($h);

In this particular case, doing data verification wasn't overly useful, but I can definately see when it might be. While I'm not convinced that using $_ "won't break any existing code," it seems to be the most perlish choice to use.

perl -pe '"I lo*`+$^X$\"$]!$/"=~m%(.*)%s;$_=$1;y^`+*^e v^#$&V"+@( NO CARRIER'

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://219978]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (5)
As of 2021-06-12 21:24 GMT
Find Nodes?
    Voting Booth?
    What does the "s" stand for in "perls"? (Whence perls)

    Results (53 votes). Check out past polls.