in reply to How may I set a bit or change (10100101 to 10100111)?

You can do bit-wise or using the | operator:
my $a6 = 0b10100101; my $a7 = $a6 | 0b0000010; printf "dec: $a7, hex: %x\n",$a7
see also perlop's section on bitwise or

update: ignore the variable names :-)

Replies are listed 'Best First'.
Re^2: How may I set a bit or change (10100101 to 10100111)?
by GrandFather (Saint) on Jun 15, 2006 at 21:18 UTC
    my $a6 = 0b10100101;

    is a little misleading as the hex value is actually 0xA5.

    Oring 2 with 0xA6 leaves the value unchanged by the way.


    DWIM is Perl's answer to Gödel