Search code examples
rakurakudo

How to execute raku script from interpreter?


I open raku/rakudo/perl6 thus:

con@V:~/Scripts/perl6$ perl6
To exit type 'exit' or '^D'
> 

Is the above environment called the "interpreter"? I have been searching forever, and I cannot find what it's called.

How can I execute a rakudo script like I would do

source('script.R') in R, or exec(open('script.py').read()) in python3?

To clarify, I would like the functions and libraries in the script to be available in REPL, which run doesn't seem to do.

I'm sure this exists in documentation somewhere but I can't find it :(


Solution

  • As Valle Lukas has said, there's no exact replacement. However, all usual functions are there to run external programs,

    • shell("raku multi-dim-hash.raku") will run that as an external program.
    • IIRC, source also evaluated the source. So you might want to use require, although symbols will not be imported directly and you'll have to use indirect lookup for that.
    • You can also use EVAL on the loaded module, but again, variables and symbols will not be imported.