How do I read back in the output of Data::Dumper?

前端 未结 9 1590
暖寄归人
暖寄归人 2021-02-10 02:14

Let\'s say I have a text file created using Data::Dumper, along the lines of:

my $x = [ { foo => \'bar\', asdf => undef }, 0, -4, [ [] ] ];
9条回答
  •  遇见更好的自我
    2021-02-10 02:50

    This snippet is short and worked for me (I was reading in an array). It takes the filename from the first script argument.

    
    # Load in the Dumper'ed library data structure and eval it
    my $dsname = $ARGV[0];
    my @lib = do "$dsname";
    

提交回复
热议问题