Welcome to the Monastery | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
The safest thing you can do is to stringify $1,$2 when them in an lvalue context. I'm not sure that is much clearer. perlglossary lists lvalue but not lvalue context, but when you compare context, scalar context and list context, and plug-in lvalue, it doesn't quite work , unless you lookn up expression and then value. Putting all that together assignment is also lvalue-context, but I wouldn't recommend needlesly quoting $1 in my $one = $1; So I might rephrase as 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. foo("$1") instead of foo($1) $bar = "$1" + foo(); instead of $bar = "$1" + foo(); No need to quote straight assignment if(m/.../){ $bar = $1; } In reply to Re^4: $1 not "freezing" in an addition
by Anonymous Monk
|
|