in reply to Junking excess string.. junk with s///.
To put it another way, if you had the string $val = "dogs and cats\nfoo and bar\ntime and taxes" then it would capture "dogs and cats" in $1 and then also capture the \n after it for the match. After which it would replace just this string with "dogs and cats" resulting in a string:"dogs and catsfoo and bar\ntime and taxes" The second snippet matches because you are capturing everything after the first "\n" (inclusive) and then replacing it with nothing (effectively getting rid of the first \n and everything after it, which is what I think you are after).
-enlil
|
|---|