echo "a#b#c#d" | tr '#' '\n' | perl -pe 's/b\nc/bc/g'