Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: assigning part of the value of an element of an (associative) array



On Dec 3, 11:10pm, Stephane Chazelas wrote:
}
} One can also do:
} 
} scalar[1,3]="foo"
} 
} To assign parts of a scalar.
} 
} But how would you assign bytes 1 to 3 of $mapfile[file.txt] for
} instance?

Extra levels of subscripting don't work in assignment, no matter what
the type of the parameter.  Even for a normal array,

ary[3][2]=x

does not assign to the 2nd character of the 3rd element.  In effect,
the first subscript ary[3] gives a reference, but the second subscript
ary[3][2] gives only a value, so the assignment is meaningless.

The file mapping stuff in zsh is pretty primitive.  It effectively
reads and/or (re)writes the entire file every time you manipulate it.



Messages sorted by: Reverse Date, Date, Thread, Author