I dont know if you are speaking of AC (line powered) or DC lights such as you might find in a flashlight. In any case, for the AC lights, you would probably want to use a triac and have your software trigger the bulb at different parts of the sinusoid. The triac when triggered stays on until the zero crossing of the AC waveform. Then in the next 1/2 cycle you trigger it in the right place again. You can do this very easily with a micro or a comparator circuit to "square up" the sinusoid. Note that you want to drop the voltage down probably with a transformer for isolation and then maybe use optical coupling to get the pulse into your PCs parallel port (which I what I assumed by db25).
If the light is a lower voltage DC type, you can use pulse widith modulation. You would set up a timer that triggers perhaps every 20ms or so, then you can turn the bulb on and setup a turn off time, maybe 5ms from now. That would mean the bulb is on 5ms and off 15ms, you do this rapidly enough and the low pass filter effect of the bulb will not be noticable. You would need to use the pin to drive some power handling parts for the bulb.