in reply to bit flag generator

That's interesting, but why didn't you just use vec()?
my $bitflags = 0; #all off. vec( $bitflags, 0, 1 ) = 1; # Set the first bit. print "First bit is set\n" if( vec( $bitflags, 0, 1 ) ); vec( $bitflags, 1, 1 ) = 1; # Set the second bit. print "Second bit is set\n" if( vec( $bitflags, 1, 1 ) ); vec( $bitflags, 0, 1 ) = 0; # UnSet the first bit. print "First bit is set\n" if( vec( $bitflags, 0, 1 ) ); print "First bit is off\n" if( !vec( $bitflags, 0, 1 ) ); # and so on...

Replies are listed 'Best First'.
RE: RE: bit flag generator
by japhy (Canon) on Jul 21, 2000 at 05:18 UTC
    vec() is not a user-friendly function, in all honesty. Bit::Vector makes it easier, but it's rarely that you have to deal with this matter. It's also much nicer to have NAMES for your bits (hmm, that sentence doesn't sound quite right).