double calculateStuff(int calculationType, char * translationFile, AV *referenceFiles, AV* report, char *extra1, int extra2) { double score = 0.0; ifstream trans(translationFile); vector refs; numRefs = av_len(referenceFiles); for (I32 i = 0; i < numRefs; i++) files[i] = new ifstream(SvPV(*(av_fetch(refFiles, i, 0)))); // figure out what the score should be switch calculationType { case 0: // do calculation type number 0 case 1: // do calculation type 1 case ... // yadayada up through type 5 default: // complain I don't know what to do } if (report) { av_push(report,newSVpv('score', PL_na)); av_push(report,newSVnv((NV)score); av_push(report,newSVpv('variance', PL_na)); av_push(report,newSVnv((NV)variance); av_push(report,newSVpv('length penalty', PL_na)); av_push(report,newSVnv((NV)lengthPenalty); //etc., etc. } return score; } MODULE = blah PACKAGE = blah void type1(char *hypFile, AV *AV_refFiles, int extra = 0) ALIAS: type5 = 5 type4 = 4 PREINIT: AV *report = 0; bool wantarray = false; double score; PPCODE: wantarray = GIMME_V == G_ARRAY ? true : false; if (wantarray) report = newAV(); score = computeScore((ix ? ix : 1), hypFile, refFiles, report, 0, extra); if (wantarray) { EXTEND(SP,av_len(report)); for (I32 i = 0; i < av_len(report); i++) PUSHs(sv_2mortal(*(av_fetch(report, i, false)))); } else { PUSHs(sv_2mortal(newSVnv((NV)score))); } void type0(char *hypFile, AV *AV_refFiles, char * extra = 0) ALIAS: type2 = 2 type3 = 3 PREINIT: AV *report = 0; bool wantarray = false; double score; PPCODE: wantarray = GIMME_V == G_ARRAY ? true : false; if (wantarray) report = newAV(); score = computeScore(ix, hypFile, refFiles, report, extra, 0); if (wantarray) { EXTEND(SP,av_len(report)); for (I32 i = 0; i < av_len(report); i++) PUSHs(sv_2mortal(*(av_fetch(report, i, false)))); } else { PUSHs(sv_2mortal(newSVnv((NV)score))); }