Let $X$ be a set, $\mathcal{A}$ and $\sigma$-algebra of subsets of $X$. Let $f,g: X \to \mathbb{R} \cup \{\pm \infty\}$ be measurable functions and $A \subseteq X$ measurable. Define $h: X \to \mathbb{R} \cup \{ \pm \infty \}$ by
\begin{equation} h(x)=\begin{cases} f(x) & \text{if $x\in A$},\\ g(x) & \text{if $x \notin A$}. \end{cases} \end{equation} Show that h is measurable.
I think that we start by showing that $A \cap h^{-1}(a, \infty] = A \cap f^{-1}(a, \infty] $ and $A^c \cap h^{-1}(a, \infty] = A^c \cap g^{-1}(a, \infty]$. And then show that $h^{-1}(a, \infty]$ is measurable for every $a \in \mathbb{R}$. Is this correct?
I think it is easier to note that $$h= f\chi_A + g \chi_{A^c}$$ and then invoke that products and sums of measurable functions remain measurable.