O munificent ones!
I've been working with binary strings, which, coming from an image file, can have any bin-value.
The following behaviour caused a lot of head scratching till I found out where the problem was:
my @strings=("ab30ff","30","ab1a30");
for (@strings){
$_=pack ("H*",$_);
}
for my $b1 (@strings){
print "here: ";
while ($b1){
my $b1=substr $b1,0,1,"";
my $bits=unpack ("B*",$b1);
print "$bits//";
}
print "\n";
}
here: 10101011//00110000//11111111//
here:
here: 10101011//00011010//
As you can see, if \x30 comes at the end of the string or the string only consists of \x30, "while" breaks off.
The strings come from a read-in filehandle, which was in binmode, but have been extracted and passed between subs.
Is there any way to force "while" to treat it as binary here.
All suggestions gratefully received