in reply to Reading Binary

One way to move through all characters in a string is with substr:
use warnings; use strict; my $str = 'ABCD'; while (my $mask = <DATA>) { chomp $mask; for my $i (0 .. length($mask)-1) { print substr($str, $i, 1) if substr($mask, $i, 1) eq '1'; } print "\n"; } __DATA__ 1001 1110 0101 0001

Replies are listed 'Best First'.
Re^2: Reading Binary
by oxone (Friar) on Jun 15, 2011 at 16:21 UTC
    I think the OP is asking about binary data, not character data that contains '0' and '1'?