the first call of ok():
the first argument is $errors && ($errors-> =~ /.../i) which results in $errors being passed as the first argument. before it is passed, array element 0 gets autovivivied though by usage in the second argument.
the second call:
$errors is now true, so the matching is executed and its result would the empty string ("false"). but since the matching is executed in list context, the result is an empty list, so what you wrote as a second argument becomes now the first argument.
like I said. the first argument passed to ok() is $errors && ($errors-> =~ /.../i).
what gets really passed is $errors. it's like saying: my @foo = $errors && ($errors-> =~ /.../i)
the pattern match isn't executed at all at the first time.
but after processing the first argument, you use $errors-> in your second argument. now $errors is autovivified to an array ref before ok() is actyally executed. since $errors is passed as the first argument as an alias, it prints ARRAY(0x137cd48)
I don't see your example as a proof for that.
argument 1: $x=0 $x is set to 0 and $x (or an alias) is passed as argument 1
argument 2: $x=$x+1 $x is set to 0+1 = 1 and $x (or an alias) is passed as argument 2
argument 3: $x++ $x is incremented and the return value of the post increment (1) is passed as the argument 3
argument 4: ++$x $x is incremented and the return value of the pre increment (3) is passed as argument 4.
$x is now 3.
argument 1 is an alias for $x. 3
argument 2 is an alias for $x. 3
argument 3 is 1.
argument 4 is 3.