I have an attribute (32 bits-long), that each bit responsible to specific functionality. Perl script I’m writing should turn on 4th bit, but save previous definitions of other bits.
I use in my program:
Sub BitOperationOnAttr
{
my $a="";
MyGetFunc( $a);
$a |= 0x00000008;
MySetFunc( $a);
}
** MyGetFunc/ MySetFunc my own functions that know read/fix value.
Questions:
-
if usage of
$a |= 0x00000008;is right ? -
how extract hex value by Regular Expression from string I have : For example:
“Attribute: Somestring: value (8 long (0x8))”
Yes, this is fine.
I’m assuming you have a string like the above, and want to use a regular expression to extract the “0x8”. In that case, something like:
should work.