- my $src = 'D:\\\\boot.bin';
- if (!-e $src) {
- die "ERROR: File \\"$src\\" doesn't exist!";
- }
- open my $boot, "<$src";
- open my $dest, ">bin.txt";
- binmode($boot);
- my $buffer = '';
- my $len = 65536;
- read($boot, $buffer, $len, 0);
- foreach (split(//, $buffer)) {
- #print $dest ord($_);
- printf $dest ("%02x", ord($_));
- #printf $dest ("%02x", ord($_));
- }
- #该片段来自于http://www.codesnippet.cn/detail/111120137054.html
来源: http://www.codesnippet.cn/detail/111120137054.html