[EMAIL PROTECTED] wrote: > Since, everyone is so lively today, I'm going to push my luck today with > this list. I need a little help here with validating a string to have only > characters that I want, A-z and _ (underscore). > > So, this is what I'm stuck on:
In what way are you stuck? > > > #should fail because of space > $username="bob by"; > > if(&isValidChars($username)) > ... > > #is there a better way but it isn't working anyway. > sub isValidChars > { my $retVal; > > @chars=split(//,$_[0]); > > for(@chars) > { > if($_ =~ /A-z/) { print "good [" . $_ . "]\n"; $retVal=1; } > else { print "bad [" . $_ . "]\n"; $retVal=0; break; } Where did you declare break. It is not part of the Perl language AFAIK. > > } > return $retval; > } The best advice I can give is to always place use strict; use warnings; before any other code in your script. FWIW, last will serve the same function in Perl as break does in C. Joseph -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]