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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |