in reply to pi and some continued fractions

Exactly, as eyepopslikemosquito said: Spigot algorithm. And here or here is ready to use program in C, which can be easily converted to Perl (but kudos for those, who can optimize it significantly for Perl golf):
/* Calculation of pi to 32372 decimal digits */ /* Size of program: 152 characters */ /* After Dik T. Winter, CWI Amsterdam */ unsigned a=1e4,b,c=113316,d,e,f[113316],g,h,i; main(){for(;b=c,c-=14;i=printf("%04d",e+d/a),e=d%a) while(g=--b*2)d=h*b+a*(i?f[b]:a/5),h=d/--g,f[b]=d-g*h;}