In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] (David Green) wrote:
>I can imagine "table context" being reasonably popular. [...] >(Taking a scalar and returning a list is less common, but I can >imagine a 2-D version of 'split' that turns a string into a table....) One way to generalise it might be to allow an array (ref) for the thing to split on. Each element of the array could specify the splitter for the corresponding dimension: @table_2D = split [/</TR><TR>/i, /</TD><TD>/i], $html_table; I guess forcing "table context" on a list would effectively turn it from a 1-D n-array into a 2-D 1xn-array. Scalar context on a 2-D table should return some sort of count (analogous with a list in scalar context), but maybe not the number of elements in the table. I think the number of records would typically be more useful. And list context on a table... it might return a list of array [refs], each containing a record -- in other words, convert the table into a p5-style nested data structure that simulates a true 2-D array. On the other hand, maybe list context simply returns a single plain list consisting of the table "headers". Actually, if we have "headings", that's very handy for DB modules, but we've gone beyond a plain array in two dimensions. A table with named fields would really be more of a 2-D hash... my %rec is shape(Int; <foo bar bat>); %rec<0;foo>="Silence is"; %rec<1>=<foosball barbell batboy>; #assign whole record at once(?) Except those Int keys are effectively used as strings that just happen to look like ints, right? That is, I'm not getting all the arrayary goodness (like pushing or popping or ordering). What I really want here is a hybrid hash-array. I suspect that there's no way to do that though (other than creating my own class and overloading array stuff to handle it for the numeric key(s)). - David "2-D or not 2-D" Green