Maybe try:
unset arr
printf %s\\
a b c | {
readarray arr
echo ${#arr[@]}
}
I expect it will work, but the moment you step out of that last `{` shell `; }` context at the end of the `|`pipeline there you'll lose your variable value. This is because each of the `|`separate `|` processes within a `|`pipeline is executed in a `(`subshell`)`. So your thing doesn't work for the same reason:
( arr=( a b c ) ) ; echo ${arr[@]}
...doesn't - the variable value was set in a _different_ shell process than the one in which you call on it.