You can try Storable or Data::Dumper with $Data::Dumper::Useqq = 1
.
Convert an array of strings into Perl source code defining a list
-
25-08-2022 - |
Question
I am parsing some website(s) to get some information list that I store into an array of strings. I need to generate .pm
code where this list will be defined as a Perl variable. As such strings in the array may contain any ASCII character, I need to ensure that there would be no conflict with Perl syntax. What is the best and safest way to convert such array into Perl source code?
Solution
OTHER TIPS
I suggest to use: FreezeThaw
It can freeze
and thaw
any element you want (or at least anything that doesn't have pointers to active objects).
If needed it also allow you to modify the freezer
and thawer
so that you can store data the regular function doesn't support.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow