• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 732
  • Last Modified:

Perl question mark syntax

Will someone explain to me what the question marks mean in the four places used in this statement?

if(m/DROP TABLE IF EXISTS \`?$tableName\`?/ || m/CREATE TABLE \`?$tableName\`?/){
2 Solutions
perldoc perlre


       The following standard quantifiers are recognized:

           *      Match 0 or more times
           +      Match 1 or more times
           ?      Match 1 or 0 times
           {n}    Match exactly n times
           {n,}   Match at least n times
           {n,m}  Match at least n but not more than m times
The statement given by you is using a regex.
In a regex there are several meta-characters.
Like the ones specified by ozo above.

? is one of the meta-characters.

This checks 0 or 1 occurrence of the preceding character


Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now