I have done this several times over the years - the easiest way (it may not seem so) is to remove the curtains and take down the rail.
Make the repair on a long table or kitchen worktop - this way you can easily access the back of the rail where the cord fits. Then put it all back again.
New cord may be bought from a hardware or DIY store - a camping shop may be better because they often have more varieties. Take a sample with you to get the diameter correct.
Good luck...
Peccavi
August 2009