Created
May 26, 2016 21:24
-
-
Save jrelo/6b9f2c01e787d7199834beb2a9f464ad to your computer and use it in GitHub Desktop.
flip single bit using perl.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[16:25:27] root@na:~ # echo "A"|xxd -b | |
0000000: 01000001 00001010 A. | |
[16:25:30] root@na:~ # echo "A"|perl -e '$byte=shift(@ARGV);$bit=shift(@ARGV);undef $/; $in=<>; substr($in,$byte,1) = substr($in,$byte,1) ^ chr(1<<$bit); print $in' 0 1|xxd -b | |
0000000: 01000011 00001010 C. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment