declaring a hash table in one file and using it in another in Perl

后端 未结 4 1196
梦如初夏
梦如初夏 2020-12-11 10:01

I need to create a hash table in one file and use in in another. The reason for it is that that the table is my \"database\" and will be changed, and I want it to seat with

4条回答
  •  渐次进展
    2020-12-11 10:38

    There are too many ways to do it!

    A simple one is to write your data to a file as CSV and load it using Text::CSV or Text::CSV_XS.

    update:

    You can also use the do builtin to read and execute a perl file from another script. I.e.:

    do "config.pl";
    

    Or use a configuration file format that allows for complex data structures (XML, JSON, yaml, .ini, etc.).

提交回复
热议问题