james28909 has asked for the wisdom of the Perl Monks concerning the following question:
In this code, it should match "1" 2 times, "2" 2 times, and "3" 3 times, which would be a total of 7 repeating bytes. The script only counts 5 repeating bytes.use strict; use warnings; my $count = 0; my @array; while ( read( DATA, my $byte, 1 ) ) { if ( $byte ~~ @array ) { $count++; print @array; undef @array; } else { undef @array; push @array, $byte; print @array; } } print $count; __DATA__ 1112223333
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Byte repetition check
by BrowserUk (Patriarch) on Dec 11, 2014 at 04:02 UTC | |
by james28909 (Deacon) on Dec 11, 2014 at 04:27 UTC | |
|
Re: Byte repetition check
by ikegami (Patriarch) on Dec 11, 2014 at 03:56 UTC | |
|
Re: Byte repetition check
by Anonymous Monk on Dec 11, 2014 at 05:05 UTC | |
|
Re: Byte repetition check
by thezip (Vicar) on Dec 11, 2014 at 21:17 UTC | |
|
Re: Byte repetition check
by james28909 (Deacon) on Dec 11, 2014 at 07:42 UTC | |
by FloydATC (Deacon) on Dec 11, 2014 at 11:29 UTC |