On 7/18/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:

i have a hex value which needs to be checked if a particular bit is
set in that string.

You probably want to start with the hex() function, which turns a
string like '01AF' into a number. But there are other ways; if it's an
arbitrarily-long hex string, you could use pack to turn it into a
bitstring.

 my $bitstring = pack("H*", '01AF');

for example, i need to check if 12th bit is set.

That's possible with the vec() function; see perlfunc.

i tried doing mask(0x1000) with my input value i receive, so that only
if 12th bit is 1, will the answer be one....but can i do a direct
comparison as in

 $mp = $inputhexval & 0x1000;

What happened when you tried it?

The & operator is documented in the perlop manpage.

Good luck with it!

--Tom Phoenix
Stonehenge Perl Training

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to