in reply to Re^3: Help displaying binary data bit-by-bit in binary notation
in thread Help displaying binary data bit-by-bit in binary notation

The following also works:

my $bin_str = unpack( "b*", $string ); print join( "\n", $bin_str =~ /(.)/g );

It avoids split plus a (magical) regexp when just a regexp will do.

It avoids split // which confuses Text::Balanced.

Replies are listed 'Best First'.
Re^5: Help displaying binary data bit-by-bit in binary notation
by japhy (Canon) on Jun 15, 2006 at 03:20 UTC
    How does Text::Balanced enter this scenario? What's the problem?

    Jeff japhy Pinyan, P.L., P.M., P.O.D, X.S.: Perl, regex, and perl hacker
    How can we ever be the sold short or the cheated, we who for every service have long ago been overpaid? ~~ Meister Eckhart
      The problem occurs if that code were to appear in something parsed using Text::Balanced, such as a Parse::RecDescent grammar. It's not relevant most of the time, but it has bitten me twice in the past.