So, as others mention, what you should be doing is simply:
$haha =~ s/tyre/tire/g;
(that's it... simple, no backticks, no need for invoking a subshell and sed, since sed is kind of just a very very limitted subset of perls functionality).

However, I'll also give the direct answer to your question: Perl and shell have a great deal in common, for example the $ sigil on variables, the interpolation of variables inside of double quotes ("...") and backticks (`...`), and the (shell) execution of a string in backticks. The important differences (for this example) are that

So in order to get the specific behavior you want doing this shell programming in perl, you'd have to do:
$haha=`echo -n $haha | sed "/tyre/tire/g"`;
There are only two actual differences (corresponding to the two bullets above):

NOTE Regarding the shell and it's "handling" of whitespace: in general, the shell is actually going to be doing a lot more than just trimming the trailing newline... what the shell does is basically split all the output on any whitespace (including spaces, tabs, newlines), ignore any leading or trailing whitespace. It will use these "words" as a list, if the backtick is used in a list context, and rejoin the split-apart "words" with single spaces if it is using the results of the backtick as a string.

------------ :Wq Not an editor command: Wq

In reply to Re: sed in perl by etcshadow
in thread sed in perl by Anonymous Monk

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.