summing the digits of a binary nuMBER

please help me write a perl program to find the difference of 1 and zeros of a 6 digit binary number.

eg If input is 111100 expected output +2
if input is 000011 expected output -2
input is 000111 expected output 0

Interested in the tool (perl) used for the solution or the solution?

 
echo "01" | perl -lane '{@a=split //;foreach(@a){if($_ == 1){$one++;}else{$zero++}}print ($one - $zero)}'