#!/usr/bin/perl -w use strict; use Parse::RecDescent; my $parser = new Parse::RecDescent (q{ L: '0' L '1' L: '' }); my $string1 = "00111"; my $string2 = "0011"; print $parser->L(\$string1) && $string1 eq '' ? "" : "not ", "in L\n"; # not in L print $parser->L(\$string2) && $string2 eq '' ? "" : "not ", "in L\n"; # in L