Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re^5: $1 not "freezing" in an addition

by ikegami (Pope)
on Dec 17, 2012 at 13:12 UTC ( #1009163=note: print w/ replies, xml ) Need Help??


in reply to Re^4: $1 not "freezing" in an addition
in thread $1 not "freezing" in an addition

lvalue context has nothing to do with scalar/void/list context.

lvalue and lvalue context are not the same thing.

An lvalue context is a context where an expression must produce an lvalue. In contrast, an rvalue context is a context where code may produce an rvalue.

Example of lvalue contexts:

  • Sub arguments.
  • The arguments to some functions.
  • The operand of the reference operator.
  • The LHS operand of assignment operators.
  • foreach's list.

When using $1,$2... in an expression ( anything you can legally say in a spot where a value is required ) you should quote to stringify and preserve the current value.

No, it's stupid to do $x = "$1";.

...though I admit the lvalue context is not sufficient (e.g. $bar = "$1" + foo();).


Comment on Re^5: $1 not "freezing" in an addition
Select or Download Code
Replies are listed 'Best First'.
Re^6: $1 not "freezing" in an addition
by Anonymous Monk on Dec 17, 2012 at 13:42 UTC

    ... An lvalue context is a context where an expression must produce an lvalue ...

    That is confusing, the $1 in  bar = "$1" + foo(); is not a location where you can assign (use = ) a value , what?

    No, it's stupid to do $x = "$1";

    Eh?

      I don't understand your questions.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (7)
As of 2015-07-31 04:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (274 votes), past polls