Perl question mark syntax

Posted on 2009-04-15
Last Modified: 2012-05-06
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\`?/){
Question by:jmicorp
    LVL 84

    Accepted Solution

    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
    LVL 5

    Assisted Solution

    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

    Enabling OSINT in Activity Based Intelligence

    Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    String Substitution 4 56
    perl rename 2 134
    hard perl script 16 137
    Reading fields from the text file. 4 80
    A year or so back I was asked to have a play with MongoDB; within half an hour I had downloaded (,  installed and started the daemon, and had a console window open. After an hour or two of playing at the command …
    In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (…
    Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now