Hi, I have tried that to no avail. I have also tried a simple match of !~ m/(m|f){1}/ and even put in the code you suggested to read !~ m/^(m|f){1}$/ but this still doesn't work properly. Input of "d" or "T" will work to say it is incorrect and input of "m" or "f" will be accepted but I was under the impression that the {1} would limit it to only accept a single character while in practice it still accepts "ff" and "mmm". Any ideas? One further question though, an example question I am doing asks for a text file to be read in and the number of digits to be counted (ie 3 "1"'s, 6 "2"'s etc) and I can read input in and do a 'getc' and pattern match that against a hash containing word references to the numbers and then add one to a count but is this the best way to do this? Thanks again, Mark
________________________________ From: John W. Krahn [mailto:[EMAIL PROTECTED] Sent: Wed 20/09/2006 01:12 To: Perl Beginners Subject: Re: Newbie Question M K Scott wrote: > Hi all, Hello, > Please forgive the newbie nature of this question but i'm just > starting off teaching myself perl from scratch and so need a little > clarification. > > I am trying to put together a script to do pattern matching and while > I can get the basic syntax alright it doesn't seem to be working as > expected. For one example I need to match a user input and make sure > it is a certain length (i.e. doesn't exceed a certain number of > characters) and this is the code so far: > > while ($string != m/[a-zA-Z]{1,5}/ ) > { print("that is wrong....try again: "); > chomp ($string = <STDIN>); } You need to anchor the pattern like /^[a-zA-Z]{1,5}$/ John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response> -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>