Well, the simple fact is nothing can be put into $_ to get the regexp some$thing to match against it because $ is more of a placeholder metacharacter to indicate to the regex engine to make matches around EOL, it doesn't actually denote or match any character per se.

Under the popular text formats an EOL is denoted by a Carriage Return or Line Feed or both. So, is it possible to try and match an EOL sequence in a string that doesn't contain either of CR or LF or CR/LF (\r, \n, \r\n respectively)? Well, No, it's simply impossible.

You have to change your regexp to try and match an actual EOL sequence after $ like this.
my $regexp = qr/some$.thing/sm; # or even qr'some$\nthing'm local $_ = "some\nthing"; print " matched $& " if /$regexp/;
You'll notice the use of qr//sm modifiers to get the regexp to work with multiline strings and get . to match newlines. The //sm modifiers are very important as normally, newlines aren't matched by . in regular expressions unless /s is used but we also are working with multiline strings, hence //sm, more info in perlretut.

Not all strings entered from STDIN are newline terminated, e.g. if you were in multi-line mode (via $/ = undef ) and CTRL+D (twice if preceding character wasn't a newline) was used to terminate input, no newline or any character for that matter is appended to the end of the input string.


perl -e '$,=$",$_=(split/\W/,$^X)[y[eval]]]+--$_],print+just,another,split,hack'er

In reply to Re^2: variable interpolation in regexps by Firefly258
in thread variable interpolation in regexps by Locutus

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.