Path: utzoo!censor!geac!torsqnt!news-server.csri.toronto.edu!cs.utexas.edu!usc!zaphod.mps.ohio-state.edu!caen!ox.com!ox.com!emv From: emv@ox.com (Ed Vielmetti) Newsgroups: comp.lang.perl Subject: Re: constructing tables (was alarm()) Message-ID: Date: 3 Dec 90 01:14:03 GMT References: <3294@medusa.informatik.uni-erlangen.de> <109564@convex.convex.com> <109679@convex.convex.com> Sender: usenet@ox.com (Usenet News Administrator) Organization: OTA Limited Partnership, Ann Arbor MI. Lines: 42 In-Reply-To: tchrist@convex.COM's message of 1 Dec 90 20:23:59 GMT In article <109679@convex.convex.com> tchrist@convex.COM (Tom Christiansen) writes: I can at least cut down on one split and the cost of storing it all as a string. Put the table at end of the program past a __END__ symbol and load in in by referencing . this is what I end up with once I'm done. one of the (unstated) requirements is to have there be only data and not code in the file, so I'm willing to absorb the subroutine call overhead: require 'table.pl'; while () { &table'simple($_, *array) } ; __END__ key1 value1 key2 value2 this works really nice, because I don't have to worry about getting the syntax of the associative array down exactly right in every pass. the table can be updated quite easily just by appending to the file rather than inserting something in the middle too. and since I have a couple of tables that are the same, the code can sit in a package off somewhere else. table.pl looks like this, with various other types of table handling (multiple keys, multiple values, escaping stuff in, etc) defined as I need them. # table.pl. load in various types of tables. package table; sub table'simple { local($_, *ary) = @_; if (!/^[ \t]$/) { ($key,$value) = split; $ary{$key} = $value; } 1; } thanks. --Ed Brought to you by Super Global Mega Corp .com