Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Zaxo,
The body of an lvalue sub doesn't get executed when it is used as an lvalue.

Not sure if that was the original behavior back in 1999 when they were first introduced but newer versions certainly disagree with you:

my %foo; get_set( 'foo' ) = 42; print get_set( 'foo' ); sub get_set :lvalue { my $key = shift; print "key is $key\n"; my $junk; $key eq 'foo' ? $foo{$key} : $junk; } __END__ key is foo key is foo 42
...You can retrieve it with $foo->get_set($bad_key)

Where $bad_key is any and all bad keys. This is why one of the desired features would be to determine if it was in assignment or not.

Cheers - L~R


In reply to Re^2: Experimenting with Lvalue Subs by Limbic~Region
in thread Experimenting with Lvalue Subs by Limbic~Region

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (3)
As of 2024-04-25 10:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found