Simple, modern, robust, transparent persistence of data structures for Perl

前端 未结 3 2211
囚心锁ツ
囚心锁ツ 2021-02-20 01:52

I\'m looking for a solution to transparently persist Perl data structures (not even objects, but object support would be a plus) without circular references. I don\'t c

3条回答
  •  既然无缘
    2021-02-20 02:31

    Why not use JSON? It's rather easy (unless I misunderstood your question), all you would do is this:

    use JSON;
    # serialize to file
    open(my $fh, ">myfile");
    print $fh encode_json($ds); 
    close $fh;
    # deserialize from file
    open(my $fh, ";
    $ds = decode_json($content);
    close $fh;
    

    Another easy thing you can do is use Data::Dumper.

提交回复
热议问题