sphalaris has asked for the wisdom of the Perl Monks concerning the following question:
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.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//
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: while loop on binary : \x30
by Corion (Patriarch) on May 16, 2016 at 16:44 UTC | |
|
Re: while loop on binary : \x30
by AnomalousMonk (Archbishop) on May 16, 2016 at 20:49 UTC | |
|
Re: while loop on binary : \x30
by Marshall (Canon) on May 16, 2016 at 19:14 UTC | |
|
Re: while loop on binary : \x30
by marioroy (Prior) on May 17, 2016 at 00:55 UTC | |
|
Re: while loop on binary : \x30
by sphalaris (Novice) on May 17, 2016 at 06:14 UTC | |
by beech (Parson) on May 17, 2016 at 07:50 UTC | |
|
Re: while loop on binary : \x30
by sphalaris (Novice) on May 17, 2016 at 17:16 UTC |