in reply to oneliner to count the number binary digits in this string 1011111

DB<34> p "1011111" =~ tr/01// 7
  • Comment on Re: oneliner to count the number binary digits in this string 1011111
  • Download Code

Replies are listed 'Best First'.
Re^2: oneliner to count the number binary digits in this string 1011111
by Anonymous Monk on Mar 13, 2021 at 23:04 UTC
     $string_len    = length($binary_number);

      DB<45> p "NOPE! 1011111" =~ tr/01// 7 DB<46> p length "NOPE! 1011111" 13 DB<47>

      > to count the number binary digits

      Cheers Rolf
      (addicted to the Perl Programming Language :)
      Wikisyntax for the Monastery