The assignment expression $bar = 9 does not return a reference to $bar (i.e. the variable itself); instead, it returns the integer value of 9 .
Or if you need a quote from manual :
The value of an assignment expression is the assigned value. That is, the value of "$ a = 3" is 3.
You cannot assign a link directly to a value, only for a variable that contains that value. Thus, your convenient single-line scanner comes out spectacularly, and you have to split it into two parts.
Boltclock
source share