I'd go for a switching regulator since you are stepping down the voltage so much. If the output was 100mA, you'd be dissipating 2W of power...at minimum input voltage!
====================
If you really wanted to use a linear regulator (an industry standard one is the LM78XX, where XX is output voltage) then you would have to attach one of two things to the input of the regulator since it can't dissipate that much energy and can only handle 12V input max-
(1) A zener diode and BEEFY resistor as a voltage chopper to dissipate the large amouts of energy so the regulator doesn't have to, and bring the voltage down to a level the regulator can handle
Regulator-
http://www.fairchildsemi.com/pf/LM/LM7805.html
Zener Diode+Resistor Voltage Chopper -
http://hyperphysics.phy-astr.gsu.edu/hbase/electronic/zenereg.html
(2) Lead the linear regulator with a regulated, or unregulated (semi-regulated) DC-DC converter, which will do the same thing as the method above without all the energy dissipation. If you choose a regulated converter, you might as well go all the way and get one that steps it straight from 34V to 5V.
===================
That said, you are wasting a lot of energy if you directly clamp the voltage from 34V to 5V with a linear regulator. At 40mA it's probably okay if you use the zener clamper -> linear regulator method. But a minimum of 760mW-1.58W is a lot of power wasted.
I would say a step-down charge pump IC, but that's probably more than you want to do (since it's probably surface mount and it's something you probably have to order from Digikey or Mouser, although not hard to wire up). If you want some efficiency, but don't want to have to huntdown a 34V>5V switching converter, I would recommend using a zener voltage to 28V or so and following with this switching regulator (or another one):
http://www.dimensionengineering.com/DE-SW0XX.htm
What are you powering and what are you powering it from? It's a bit strange the source voltage is so high.