Data::Dumper - ãã¼ã¿ããã³ããã
Perl
›
ã¢ã¸ã¥ã¼ã«
›
here
Data::Dumperã¢ã¸ã¥ã¼ã«ã使ãã¨ãハッシュã配列ãªã©ã®å¤æ°ã®å 容ãè¦ãããå½¢ã§åºåãããã¨ãã§ãã¾ããã¾ãリファレンスã使ç¨ããè¤éãªãã¼ã¿æ§é ãè¦ãããåºåãããã¨ãã§ãã¾ãã
use Data::Dumper; # ãã¼ã¿ããã³ã my $dump_string = Dumper $data;
Dumperé¢æ°ã使ç¨ããã¨ãã¼ã¿ãè¦ãããæååã«å¤æãããã¨ãã§ãã¾ããDumperé¢æ°ã¯åºåãè¡ããªããã¨ã«æ³¨æãã¦ãã ããã
ç»é¢ã«åºåã«åºåãããå ´åã¯ãprint関数ãwarn関数ã¨çµã¿åããã¾ãã
print Dumper $data; warn Dumper $data;
Data::Dumperã®ããã¤ãã®ä¾ãç´¹ä»ãã¾ãã
é åãåºåãã
Dumperã®å¼æ°ã«ã¯ãé åã®ãªãã¡ã¬ã³ã¹ã渡ãã¦ãã ããã
my @nums = (1, 2, 3); print Dumper \@nums;
é åã®ãªãã¡ã¬ã³ã¹ãåºåãã
print Dumper [1, 2, 3];
ããã·ã¥ãåºåãã
Dumperã®å¼æ°ã«ã¯ãããã·ã¥ã®ãªãã¡ã¬ã³ã¹ã渡ãã¦ãã ããã
my %score = (math => 97, english => 80); print Dumper \%score;
ããã·ã¥ã®ãªãã¡ã¬ã³ã¹ãåºåãã
print Dumper {math => 97, english => 80};
Data::Dumperã«é¢ããFAQ
Q. Data::Dumperã§æ¥æ¬èªãåºåããã¨æ¥æ¬èªã§ã¯ãªã16é²æ°ã®è¨å·ã®ãããªãã®ã«ãªã£ã¦ãã¾ãã¨ããããã®ã§ããã解決çã¯ããã¾ããã
A. ããã¯å é¨æåå(â»1)ãåºåãããã¨ãã¦ããããã«èµ·ãã£ã¦ãã¾ããåºåããæååã¯å é¨æååã§ã¯ãªããã¤ãæååã§ããå¿ è¦ããã¾ããã¨ã¯ãããããã·ã¥ãé åã®ä¸ã«å«ã¾ãããã¹ã¦ã®æååããã¤ãæååã«å¤æãããã¨ã¯å¤§å¤ã ã¨æãã¾ãããããå©ãã¦ãããData::Recursive::Encode.pmã¢ã¸ã¥ã¼ã«ã¨ãããã®ãCPANã«ããã¾ãã®ã§ãData::Dumperã¨çµã¿åããã¦å©ç¨ãã¦ã¿ãã®ãããã¨æãã¾ãã
â»1 å é¨æååã¨ãã¤ãæååã«ã¤ãã¦ã¯Encodeモジュールの解説ãã覧ãã ããã
Perl
›
ã¢ã¸ã¥ã¼ã«
›
here