You can do that with any language that has an eval function. Eval takes a string and feeds it into the interpreter.
But code generation and execution during runtime, which is what I think you meant, is capable in any language with eval().
Perl claims to have a compilation stage, by which the documentation means that the lexer and parser produce an optree, which the runtime phase traverses. During that compilation stage, it's possible to run code which changes how the parser will treat subsequent syntactic elements.