in reply to binary problem
The idea is quite simple :
Just split up the string at every 1 and then count how long the sequences of zeroes are that you got back. As a one-liner, this looks like
perl -e "print length,qq(\n) for split /1/,'10000000000001000000000000 +00100';"
As a full-blown Perl program, this would look somewhat like this :
#!/usr/bin/perl -w use strict; while (<DATA>) { my @bits = split /1/; # every string starts with a 1, so # pop the first zero off of @bits pop @bits; print join( ",", @bits ), "\n"; }; __DATA__ 1000000000000100000000000000100
perl -MHTTP::Daemon -MHTTP::Response -MLWP::Simple -e ' ; # The $d = new HTTP::Daemon and fork and getprint $d->url and exit;#spider ($c = $d->accept())->get_request(); $c->send_response( new #in the HTTP::Response(200,$_,$_,qq(Just another Perl hacker\n))); ' # web
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: binary problem
by rjray (Chaplain) on Mar 07, 2002 at 22:06 UTC |