See perlretut and perlre for a start. If you are new to Perl then have a good browse around the Tutorials section here too.

A small nomenclature note: the "regular expression" is the bit that does the matching. In a substitution it is the first expression. In a match it is the only expression. In a substitution the other expression is called the substitution expression.

For complicated regular expressions it is often helpful to use the /x switch which allows you to use white space and comments in your expression so that it is easier to see the different parts and to provide comments for the parts of the expression.


DWIM is Perl's answer to Gödel

In reply to Re^3: How to match and transform a multiline pattern? by GrandFather
in thread How to match and transform a multiline pattern? by nbhatia

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.