emv@ox.com (Ed Vielmetti) (01/31/91)
I'm not sure whether to use associative arrays or regular arrays in this situation: client: which files have string "blurfl" server: "blurfl" found in "14.Z 15.Z 25.Z 344.Z 455.Z" client: which files have string "baz" server: "baz" found in "15.Z 455.Z 1023.Z" option 1: store the data in first-class arrays @key_blurfl and @key_baz, e.g. $key_blurfl[0] = "14.Z". good: straightforward list representation. picking out one element is cheap. straightforward to do uniq's, joins, intersects. bad: ugly, confusing evals needed to get at the names. no arbitrary non-alphanumerics in names. need another assoc array anyway to keep track of all those names. hard to save state between sessions. option 2: store the data in associative array %key. then $key{"blurfl"} = "14.Z 15.Z 25.Z 344.Z 455.Z"; good: more simple. perhaps more perl-like. arbitrary keys. save state between sessions just by saving array to disk. single array. bad: more expensive to pick out single elements. structure embedded in ascii strings is asking for trouble. lots of copying needed to do uniq's, joins, intersects. size limits on DBM keys ? My first pass at the problem uses option 1, but I'm really quite confused in constructing evals. I don't have a good reason to not switch to option 2, except lacking some proper idioms to deal with these lists. --Ed Edward Vielmetti, emv@ox.com