in reply to Comparing $_ --- before/after
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.)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Comparing $_ --- before/after
by mrc (Sexton) on Oct 11, 2009 at 06:12 UTC | |
by Marshall (Canon) on Oct 12, 2009 at 03:35 UTC | |
by mrc (Sexton) on Oct 12, 2009 at 06:28 UTC | |
by Marshall (Canon) on Oct 12, 2009 at 07:29 UTC | |
by ssandv (Hermit) on Oct 11, 2009 at 06:17 UTC |