Perl Binary turn Hex

Thread Starter

Anthony Quah

Joined Dec 1, 2007
80
hi guy,

Need some advice, i try convert Inputfiles.txt which is in binary to Hex into output files but keep getting the value add together.

Inputfiles.txt
PA 110011011
PB 000101
PC 111111111100


The output should look exactly like this like this even with PA,PB and PC (Outputfiles.txt)
PA 19B
PB 05
PC FFC


My command : Bin2Hex.pl Inputfiles.txt Outputfiles.txt
I need some help/advice from you guy what is the wrong with my coding. Please view attachment.. sorry unable to upload in .pl extension I write it as .txt instead
 

Attachments

coldpenguin

Joined Apr 18, 2010
165
I would start with a change like this, but it is possibly just the way I code
Rich (BB code):
   while ($b=<IN>) {
        ($name,$val)=split(/\s/,$b);
      $n = length($b);
      $byteCount += $n;
      $s = 2*$val;
      print (OUT "$name ".unpack("H$s", $val), "\n");
   }
 
Top