On Mon, 19 Mar 2001 abigail@foad.org wrote: > On Mon, Mar 19, 2001 at 10:18:43AM -0600, Chris Stith wrote: > > On Sun, 18 Mar 2001 nick@ing-simmons.net wrote: > > > > > <abigail@foad.org> writes: > > > >On Mon, Mar 12, 2001 at 11:59:24AM +0000, Nick Ing-Simmons wrote: > > > >> > > > > > > > > print 'foo'=~/(.*)/ && $1, 'bar'=~/(.*)/ && $1, "\n"; > > > > > print 'foo'=~/(.*)/ && "$1", 'bar'=~/(.*)/ && "$1", "\n"; > > > > > > In this case I assume that there is an existing body > > > of code that expects $1 to to be the last value matched, > > > so that making a copy > > If there is, then that code is wrong. Code should never depend > > upon the order of evaluation within a single statement. Even > > when order of execution within a statement is defined by the > > language, it is a bad habit to count on it. > > The only order of evaluation that the give example depends on is > that && evaluate its left operand before its right operand, and > that function arguments are evalutated before the function is > called. That is so if the examples are taken exactly as is. It is not so if the example is put in the context of code following it. From which match operator would the next line pull `$1'? Nick is talking about a body of code expecting something to be a certain way when the code example above is executed. A line of code following the above example shouldn't expect one or the other expression to be either `first' or `last', let alone expect which one will be the value of `$1'. Chris StithThread Previous | Thread Next