The main term of the asymptotic formula for $\sum_{n \leq x}\, d(n)$ is $x \log{(x)} + (2 \gamma -1)x$ (via hyperbola method). However, the goal is to obtain this using the integral (Perron's integral), $$\dfrac{1}{2\pi i}\,\int_{a-iT}^{a+iT}\, \dfrac{x^s \zeta^2(s)}{s} ds \, \, ,$$ where $a>1$.
We need to evaluate the residue at the pole $s=1$ for $\dfrac{x^s \zeta^2(s)}{s}$, which can be rewritten as, $\dfrac{x x^{s-1} \zeta^2(s)}{1+(s-1)} $ (in order to apply the residue theorem). I also know the expressions for, $$x^{s-1} = 1 + (s-1) \log{(x)} + (s-1) \dfrac{\log^2 (x)}{2!} +...$$ $$\zeta (s) = \dfrac {1}{s-1} + \gamma + c(s-1)+...$$
However, I have difficulty putting all this together. Any help would be appreciated.
The residue is the coefficient of the $(s-1)^{-1}$ term in the Laurent series at the pole. Since you know the Laurent series of all the factors, you just need to multiply them and extract the coefficient. With
$$ x^{s-1}=1+(s-1)\log x+O\left((s-1)^2\right)\;, $$
$$ \zeta(s)=\frac1{s-1}+\gamma+O(s-1) $$
and
$$ \frac1{1+(s-1)}=1-(s-1)+O\left((s-1)^2\right)\;, $$
we have
\begin{eqnarray} x\cdot x^{s-1}\cdot\zeta^2(s)\cdot\frac1{1+(s-1)} &=& x(1+(s-1)\log x)\left(\frac1{s-1}+\gamma\right)^2(1-(s-1))+O(1) \\ &=& x\left(\frac1{(s-1)^2}+\frac{\log x+2\gamma-1}{s-1}\right)+O(1)\;, \end{eqnarray}
so the residue at $s=1$ is $x(\log x+2\gamma-1)$.