Hi Dan,
On 2010-03-20 02:09, [email protected]:
Thank you for the thorough explanation. I've been aware of that
behavior, but I hadn't previously used nameref variables. I was
thinking of the nameref as giving me direct, sort-of-real-time,
no-intermediaries-involved, access to that associative array.
That's how it works, but you have another problem. A nameref
does not cross process boundaries.
typeset -A a
nameref ref=a
(
ref[jdoe]='John Doe'
print "a : " ${#a[*]}, ${!a[*]}, ${a[*]}
print "ref : " ${#ref[*]}, ${!ref[*]}, ${ref[*]}
)
print "a : " ${#a[*]}, ${!a[*]}, ${a[*]}
print "ref : " ${#ref[*]}, ${!ref[*]}, ${ref[*]}
Resulting in:
a : 1, jdoe, John Doe
ref : 1, jdoe, John Doe
a : 0, ,
ref : 0, ,
I'm using ( ) to create a subshell, your example uses a pipeline, which
has the same effect. There are two copies of the array/array_ref pair
in your example, one pair gets assigned to in a subshell, the other one
only processes the 'while read; do :; done' loop.
Henk
_______________________________________________
ast-users mailing list
[email protected]
https://mailman.research.att.com/mailman/listinfo/ast-users