Clearly, dot star is evil. The extent of its vicious machinations was just now made known to me. Because I had chanced upon the one situation to which I thought dot star was perfectly suited.

You see, I wanted to match everything. No exceptions. I wanted to slurp up the whole freakin' input. I wanted to match a certain beginning word, then match everything that followed it, and use s/// to replace just that word and one little character near the end. Instead of ending );, it was just going to end with ;.

$line =~ s/wordone\s*\((.*)\)\;//wordtwo\:$1\;/

So what had read "wordone(hello);" would now read "wordtwo:hello;" Very simple. And no matter how much was between those parentheses, I wanted it all, to just suck up the whole world.

But then my code went from suck to blow.

I thought that I had found the one good use for dot star, because I truly did want a greedy match of everything under the sun.

But dot star doesn't match newlines, it seems.

So instead of matching too much or too little, it instead matched nothing at all. Since there was no match, there was no substitution. And clearly, dot star is completely useless for anything except breaking your code.

Death to dot star! Long live ([^\)]*)!

We live in a society exquisitely dependent on science and technology, in which hardly anyone knows anything about science and technology.
- Carl Sagan


In reply to Ode to Death to Dot Star by DeusVult

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.