...anyway, I'm now too bored to think whether that's the correct solution and I'll leave the rest of that little programming exercise to you.for my $str (@strs) { my $len = ( () = $str =~ m{ 0+ | 1+ }xg ) + ( $str =~ m{ 000 | 111 | (.)\1 .* (.)\2 }x ? 2 : $str =~ m{ (?: ^ (.)\1 | (.)\2 $) }x ? 1 : 0 ); print $len, "\n"; }
Your problem is that you're trying to write overly compact code even though you don't know Perl very well. And, naturally, writing the retarded equivalent of JAPHs is not a good way to learn Perl - or any programming language, for that matter. Just saying.
I recommended you to learn Forth a while ago, and I still do. BUK suggested Python, but its significantly more verbose than Perl and you won't like it.
In reply to Re^8: How to match more than 32766 times in regex?
by Anonymous Monk
in thread How to match more than 32766 times in regex?
by rsFalse
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |