Hi all,
This is a script which converts hex to bin. However am finding an error while executing
syntax error near unexpected token `='
`($hexfile, $binfile) = @ARGV;'
I am running using ./fil.pl <hexfile> <binfile>
###################################################
#
# this script takes hex representation and generates binary file
#
# Syntax: DP_HextoBin.pl <hex file> <bin file>
($hexfile, $binfile) = @ARGV;
open f1, "<$hexfile" or die $!;
open f2, ">$binfile" or die $!;
binmode f2;
$binOut = "";
while (<f1>) {
chop;
if ($s =~ m/^0x[0-9a-f]{6}((\s[0-9a-f]{2}){1,16})/i)
{
$ss = $1;
$ss =~ s/^\s+//;
@arr = split(/\s+/, $ss);
@arr1 = map pack("H2", $_), @arr;
for my $hexv (@arr1) {
print f2 $hexv;
}
} else {
print "no matched";
}
}
close(f1);
close(f2);