Let $\displaystyle x$ be the amount of the cork that's been extracted so there is $\displaystyle l-x$ of the length of the cork that is not extracted. This part is subject to a constant pressure of $\displaystyle P$ and this acts on the curved surface of the cork. This surface has area of $\displaystyle 2 \pi r (l-x)$ so the total force (normally) against the glass of the bottle is

$\displaystyle F_N = 2 \pi r (l-x) P$

The friction force, $\displaystyle F_{\mu}$, is then

$\displaystyle F_{\mu} = \mu F_N = 2 \mu \pi r (l-x) P$ .

The work, $\displaystyle W$, done is then

$\displaystyle W = \int_{0}^{l} F_{\mu} \, \mathrm{d}x$,

$\displaystyle = 2 \mu \pi r P\int_{0}^{l} (l-x) \, \mathrm{d}x$,

$\displaystyle = 2 \mu \pi r P \left[lx-\frac{x^2}{2}\right]_{x=0}^{x=l}$,

$\displaystyle = \pi \mu r l^2 P$.