You code has worked perfectly for my problem!!! I agree that my problem was one that needed more than just regular expression. However I was struggling to get an elegant solution in perl.
Could I please ask you to explain me these two lines:
in reply to Re: string match using with an N in any position
in thread string match using with an N in any position
my $matched = ( $q ^ substr( $t, 0, length( $q ) ) ) =~ tr[\0]
if( $matched >= ( length( $q ) -1 ) )