in reply to Junking excess string.. junk with s///.

What the first snippet of code does (i.e. $val =~ s/^(.*)\n/$1/; ) is capture from the beginning everything up to the first "\n" (as you mentioned . does not match \n without the /s modifier on the regex), and puts it in $1. To complete the match it also matches the "\n". The thing that you are missing is that it does not do anything to the rest of the string, but substitute the part that was matched with whatever is in the replacement part (i.e. $var =~ s/match/replace/; will replace the first instance of match in $var and replace it with replace.)

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