In my script i am dealing with binary value and i need to replace 0->1 and 1->0 at one place.
example : input digit = 10101001 output digit = 01010110
I tried $string =~ s/1/0/;
and reverse function
but that is getting fail to give me correct out put.
can some one help me out.
Use tr:
my $str = '10101001';
$s =~ tr/01/10/;
print "$s\n";
Outputs:
01010110
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With