in reply to A (non) reg-ex question

Assuming the language consists of 1s and 0s...

sub belongs_to_L { my ($s) = @_; my ($num_zeros,$num_ones,$junk); ($num_zeros,$num_ones,$junk) = ( $s =~ m/^(0*)(1*)(.*)/); return 1 if ( length($zeros) == length($ones) and length($junk) == 0); return 0; }