BTW Do you have anything against slashes for regular expressions? It's the default, and it's what people are used to: /$search_term/i

Changing it without reason is unnecessarily obfuscating.

Far from obfuscating regexps, alternate delimiters to '/' can help to clarify. From perldoc perlre:

Modifiers are usually written as "the /x modifier", even though the delimiter in question might not really be a slash.

. . .

You can use The /x modifier to break up your regular expression into (slightly) more readable parts.

. . .

Taken together, these features go a long way towards making Perl's regular expressions more readable.

From the Perl Cookbook (1st ed.) Recipe 6.4 Commenting Regular Expressions:

For aesthetics, the example uses alternate delimiters. When you split your match or substition over multiple lines, it helps readability to have matching braces. Another common reason to use alternate delimiters is when your pattern or replacement contains slashes, as in s/\/\//\/..\//g, alternate delimiters makes such patterns easier to read as in s!//!/../!g or s{//}{/../}g

Slashes may be what most of us are used to seeing in single-line regexps, but alternate delimiters have their place too.


In reply to Re^3: What does this mean? by Cuhulain
in thread What does this mean? by biginingperl

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.