Start REPL with definitions loaded from file

本小妞迷上赌 提交于 2019-12-07 08:44:45

问题


Is there a way to start the Perl 6 REPL with definitions loaded from a file?

I.e. let's say I have this in test.p6:

sub abc() { say 123; }

I'd like to be able to start the perl6 REPL and load that file so that I can use abc interactively.


回答1:


I guess the easiest way would be to put your code in a .pm6 file, e.g. ./Foo.pm6, mark the subroutines in question with is export and then start Rakudo Perl 6 like this:

$ perl6 -I. -MFoo
To exit type 'exit' or '^D'
> abc
123


来源:https://stackoverflow.com/questions/45290418/start-repl-with-definitions-loaded-from-file

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!