vertigo said:
Hello
How can i check if $mystring is exactly equal to "."
Where "." means one character (comma) ?
If you only want a comma, use
if( $mystring eq ',' ) {
# do something if it's a comma
}
If you want any one-character string:
if( $mystring =~ m/^.$/ ) {
# do something if it's one character
}
or even better
if( length($mystring) == 1 ) {
# it's one character
}
Note the different comparison operators:
eq for string compare
=~ for pattern match
== for numerical compare
This newsgroup is defunct. Try comp.lang.perl.misc in the future.