On Tue, 26 Feb 2008 15:47:38 +0000 Ben Morrow <> wrote:
BM> Quoth BH <>:
>>
>> I am reading from a spreadsheet using Spreadsheet::BasicRead, I have
>> got a big list of variables using saying which header is in which
>> column. I want to store these in another file.
>>
>> How do I do this?
>>
>> e.g.
>> require "constants.pl";
>>
>> use spreadsheet_constrants;
>>
>> Which one is better practice?
BM> The second. However, you may find it more awkward if you really want a
BM> big list of variables to import. A better option would be to put these
BM> constants into a single hash, instead, and then import that; a third
BM> would be to use the 'constant' module to define proper named constants.
The OP could put all that data in a file (YAML, XML, CSV, etc). It
would be faster on load too, if the list is big. I can't tell the OP
what format to use since I don't know how the header name and the column
name are defined, but probably even something as simple as
1 name
2 address
3 zip code
in a plain text file would work, to be processed with
split " ", $line, 2;
I've said it before and I'll say it again, storing pure data in code is
a bad idea, especially if the data structure is simple.
Ted
|