To test whether a variable matches a string, use the =~ operator:
$a = 'gatttccaa'; print "contains three t's" if $a =~ /ttt/; print "contains an EcoRI site" if $a =~ /gaattc/ |
Some symbols between the // are special:
$a = '367-8380'; print "This is an OK telephone number.\n" if $a =~ /^\d\d\d-\d\d\d\d$/; |
|
| Contents |
Next |