我有一个变量$photo(已经base64编码的巨大字符串),我相信我需要使用MIME :: Base64解码它
用这样的东西:
用这样的东西:
my $decoded= MIME::Base64::decode_base64($photo);
现在之后我怎么把$解码回原来的jpg?
解决方法
您可以将其写入文件,就像您可以编写任何其他数据一样.但是你需要设置
filehandle to binary.
my $decoded= MIME::Base64::decode_base64($photo); open my $fh,'>','photo.jpg' or die $!; binmode $fh; print $fh $decoded; close $fh