use strict; use warnings; use utf8; use Data::Dumper; use Encode qw/encode decode decode_utf8 encode_utf8 from_to/; my $inp = decode('utf8', ); my @array = split(" ", $inp); my($a ,$b) = @array; while ($b != 0) { my $c = ($a & $b) << 1; $a ^= $b; $b = $c; } print $a;