Hello Perl_Programmer1992, and welcome to the Monastery!
“The preceding character” means the single, immediately preceding character, in this case m. But the character before that — another m — is not present in the string held by the variable $what, so there is no match. If you change the regex to /com?a/, it matches.
Other metacharacters: + matches one or more of the preceding character; * matches zero or more of the preceding character; . (dot) matches any one (single) character (except a newline). Parentheses () are used for capturing: reading from left to right, the captured strings are available in the special variables $1, $2, etc. See “Metacharacters” under perlre#The-Basics.
Hope that helps,
| Athanasius <°(((>< contra mundum | Iustus alius egestas vitae, eros Piratica, |
In reply to Re: Conceptual doubt in metacharacters : Beginner in perl
by Athanasius
in thread Conceptual doubt in metacharacters : Beginner in perl
by Perl_Programmer1992
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |