P is for Practical | |
PerlMonks |
Re: oneliner to count the number binary digits in this string 1011111by BillKSmith (Monsignor) |
on Mar 13, 2021 at 16:31 UTC ( [id://11129576]=note: print w/replies, xml ) | Need Help?? |
If you know that the string contains only binary digits, use length('1011111'). Use LanX's method if you wish to ignore non-binary characters.
Bill
In Section
Seekers of Perl Wisdom
|
|