in reply to how to pack bits, flags and masks

Hi

I'm confused. Why can't you just leave everything in Perl's internal format?

#-- set up the vars to be like what Win32::TieRegistry returns (a stri +ng and a number); my ($dword, $type) = ( '0x00500000', 4); if ( $type == 4 ) { $dword = hex $dword; } printf "Dword:\tdec:%d\thex:%x\n", $dword, $dword; my $mask = 0x00400000; printf "mask:\tdec:%d\thex:%x\n", $mask, $mask; my $flags = 0x00100000; printf "mask:\tdec:%d\thex:%x\n", $flags, $flags; my $testdw = $dword & $mask; my $newdw = $dword | $flags; printf "TestDW:\tdec:%d\thex:%x\n", $testdw, $testdw; printf "NewDW:\tdec:%d\thex:%x\n", $newdw, $newdw;
Results

Dword: dec:5242880 hex:500000 mask: dec:4194304 hex:400000 mask: dec:1048576 hex:100000 TestDW: dec:4194304 hex:400000 NewDW: dec:5242880 hex:500000
I think you still need the first $dword = hex $dword; as the return from Win32::TieRegistry is a string.

- j