in reply to Converting Perl code to C++ code

... I cant [sic] seem to get perl working.
As this is Perl site, and as you presumably have a Perl script that works just fine in another context, it might be worth while exploring just why Perl or the script doesn't work for you.

Also: In order to avoid vexing the gentle monks unnecessarily, please consider Updating your original post to use  <readmore> tags around the wall of code you have posted. Please see Markup in the Monastery et al.