#!/usr/bin/perl -w $S="[01]"; print "\nEnter string: "; while () { chomp; print "The string matches: "; print "1 " if /^0*10*$/; print "2 " if /^$S*1$S*$/; print "3 " if /^$S*001$S*$/; print "4 " if /^($S$S)*$/; print "5 " if /^($S$S$S)*$/; print "6 " if /^(01|10)$/; print "7 " if /^(0|1|0$S*0|1$S*1)$/; print "8 " if /^$/; print "6x " if /^01|10$/; # this is wrong print "7x " if /^0|1|0$S*0|1$S*1$/; # this is wrong print "\n"; print "\nEnter string: "; }