So, this is going to be the part where people are going to start getting snarky. You've waved your hands and said "I want the differences" without explaining what you mean, you gave exactly one toy example which is hardly sufficient to specify anything, and you've given weak reasons for not wanting to include a module or steal the code from one, and no actual reason not to use a shell function other than "it wouldn't be pure Perl". (Don't you think the code in a module is likely to be reasonably compact and solid? Why do you expect to get something better here?)

If you want a decent answer, you'll have to explain yourself thoroughly. (And tell us what the full problem you're attempting to solve is, this sounds like an XY problem. Or homework.) Your criteria sound increasingly absurd without a better explanation. Is your next complaint going to be that you want a one-liner?

Define and explain the expected result for the following, and we might get *somewhere*:

"Banana" / "banana" "banana" / "Banana" "Bananananafofana" / "Bafana" "Bafana" / "Bananananafofana" "Banana" / "anaBanana" "anaBanana" / "Banana" "Banana" / "Bazaza" "Banana" / "Bannana" "Bannana" / "Banana"

Or else, do what I said up above, and do the printing immediately after the substitution when you know what you've swapped out. (Hint: the different letters are probably whatever's in the right hand side of the s/// if the substitution works, at least for your example where it's a simple string.)


In reply to Re: Comparing $_ --- before/after by ssandv
in thread Comparing $_ --- before/after by mrc

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.