如何使用 Perl 6 运行外部程序?(例如,像 Perl 5 中的“系统") [英] How can I run external programs using Perl 6? (e.g. like "system" in Perl 5)

查看:78
本文介绍了如何使用 Perl 6 运行外部程序?(例如,像 Perl 5 中的“系统")的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以在 Perl 5 中使用 system 来运行外部程序.我喜欢将 system 视为 Perl 中的微型Linux 命令行".但是,我在 Perl 6 中找不到 system 的文档.什么是等效的?

I can use system in Perl 5 to run external programs. I like to think of system like a miniature "Linux command line" inside Perl. However, I cannot find documentation for system in Perl 6. What is the equivalent?

推荐答案

除了使用 shellrun,它替换了 Perl 5 中的 system,你也可以使用NativeCall 调用 libc system 函数.

在我的 Windows 机器上,它看起来像这样:

On my Windows box, it looks like this:

use NativeCall;
sub system(Str --> int32) is native("msvcr110.dll") { * };
system("echo 42");

这篇关于如何使用 Perl 6 运行外部程序?(例如,像 Perl 5 中的“系统")的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆