in reply to sed in perl
(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).$haha =~ s/tyre/tire/g;
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
There are only two actual differences (corresponding to the two bullets above):$haha=`echo -n $haha | sed "/tyre/tire/g"`;
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
|
|---|