Sorry - more questions on binary stuff.
I've got a 12 byte value obtained using:
I want to be able to AND (assign not test) it with another value say:
I'm not sure how to use the & operator in Perl - I assume I can't do:
because main_bin isn't a hex string?
I also need to convert the output back to a 96 bit binary value so that I can dump it into a database (mysql char[12] binary). Is there a way I can AND the 2 values without converting to a hex array - cut out the middle man?
I know Perl isn't the best for this sort of thing but I'm constrained for other reasons.
Thanks for your help,
rotis23
I've got a 12 byte value obtained using:
Code:
$in_bin = unpack("H2" x 12,$input_from_socket);
Code:
@main_bin = (0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01);
Code:
$i=0;
foreach $byte (@bin_out)
{
$main_bin[$i] = $main_bin[$i] & $byte;
$i++;
}
because main_bin isn't a hex string?
I also need to convert the output back to a 96 bit binary value so that I can dump it into a database (mysql char[12] binary). Is there a way I can AND the 2 values without converting to a hex array - cut out the middle man?
I know Perl isn't the best for this sort of thing but I'm constrained for other reasons.
Thanks for your help,
rotis23