问题描述
如果没有在命令行上给出文件,是否有更优雅的方式来处理来自命令行参数或STDIN
的输入?我目前正在这样做:
sub MAIN(*@opt-files,Bool :$debug,... other named options ...) {
# note that parentheses are mandatory here for some reason
my $input = @opt-files ?? ([~] .IO.slurp for @opt-files) !! $*IN.slurp;
... process $input ...
}
还不错,但是我想知道是否缺少一些更简单的方法吗?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)