[英]In Perl, how can I write the output of Dumper to a file?
Don't forget that you can specify the file handle to print
to as in 不要忘记您可以指定要
print
的文件句柄
print $LOG Dumper( \%some_complex_hash );
or use File::Slurp : 或使用File :: Slurp :
write_file 'mydump.log', Dumper( \%some_complex_hash );
Further thoughts: You might want to get into the habit of using: 进一步的想法:你可能想养成使用的习惯:
warn Dumper( \%some_complex_hash );
and redirecting standard error to a file when you invoke your script (how you do this depends on the shell). 并在调用脚本时将标准错误重定向到文件(如何执行此操作取决于shell)。 For example:
例如:
C:\Temp> sdf.pl 2>dump
使用打印
print FILE Data::Dumper->Dump($object);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.