perl -Mre=debug -e '"hello world" =~ /l.w/'
will display debugging information about the matching process.

Is there a way to show the results in some other format (e.g. to include HTML markup?) Update: output of the above call added

Freeing REx: `","' Compiling REx `l.w' size 6 Got 52 bytes for offset annotations. first at 1 1: EXACT <l>(3) 3: REG_ANY(4) 4: EXACT <w>(6) 6: END(0) anchored `l' at 0 (checking anchored) minlen 3 Offsets: [6] 1[1] 0[0] 2[1] 3[1] 0[0] 4[0] Guessing start of match, REx `l.w' against `hello world'... Found anchored substr `l' at offset 2... Starting position does not contradict /^/m... Guessed: match at offset 2 Matching REx `l.w' against `llo world' Setting an EVAL scope, savestack=3 2 <he> <llo world> | 1: EXACT <l> 3 <hel> <lo world> | 3: REG_ANY 4 <hell> <o world> | 4: EXACT <w> failed... Setting an EVAL scope, savestack=3 3 <hel> <lo world> | 1: EXACT <l> 4 <hell> <o world> | 3: REG_ANY 5 <hello> < world> | 4: EXACT <w> failed... Setting an EVAL scope, savestack=3 9 <hello wor> <ld> | 1: EXACT <l> 10 <hello worl> <d> | 3: REG_ANY 11 <hello world> <> | 4: EXACT <w> failed... Match failed Freeing REx: `"l.w"'

In reply to alternate markup for the 're' pragma by szabgab

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.