I can't speak for the B31, but I pulled the shaft on my O'Day 322 last year. Getting the coupling off the shaft was a bit of an ordeal...but if you are trying to salvage the shaft, you will need to get the coupling off. And of course, if you are installing a new shaft, you will need to see if you can get it past the rudder.
I removed the coupling, removed the stuffing box and hose, and then pressed out the cutlass bearing. With that done, I had enough lateral play to get the shaft past the rudder. Otherwise, it was lined up with the rudder.
Getting the new shaft in was harder...got the shaft started in the strut (without the cutlass bearing) and the shaft was pressed up against the rudder. Then I had to work to get the shaft into the shaft log. That took a lot of force (and wanted to be careful to not bend the strut or the new shaft. In the end, I got it,but it was not easy.
On the Beneteau, I think your shaft is enclosed in a bit of a skeg farther back than my O'Day. And I think that will make the job a lot harder.
Here is a video of the shaft removal and installation...
Good luck,
Greg