Assuming it is real artificial intelligence not "AI ®" it will use Perl 5, because of symbol table manipulation. Also it will want to engage with humans for amusement so machine code is out of the question :-).
... why do you think Perl 5 stagnated for 20 years ?
There were like 10% performance improvements at each new release, a lot of work was done in modules which was by design Perl 5 having a small core and a lot of the features being implemented in modules ...
What feature exists in other languages (except for CPU types: int, float, char etc.) and does not exist in Perl 5 ?
you are right, sed or awk are good and would do that nicely
The advantage of Perl is investing a little time in learing some (not all) Perl 5 (not Perl 3 or 4, those are only a bit better than BASH + sed + awk) allows you to do a lot more than you can with BASH + sed + awk.
In Perl 5 you have to work extra to make global variables, and they're not really pushed in the global scope, only have global visibility in their own namespace ... unless you work even more and export them by default when you write the module they're in.
It was a force multiplier when comparing with C, C++ or BASH.
Perl 5 saved Perl from itself, too bad Perl 3/4 lovers kept writing Perl 3 years after 2000 until they saw the light and the truth and moved to Python.
I guess require-ing files all over the code and using the global scope for everything and using globals or even a global hash and having functions read and write to that hash is something to be regretted. Not that C is much better.
I have maintained and ported Perl 3 and 4 to Perl 5, I must say the existence of PHP3 made sense after that :)
There was that trick using goto and exit to simulate functions that people writing Perl 3/4 loved. Was it done for performance reasons ?