有没有一种方法可以将perl一行变成bash函数?
#!/bin/bash
# ~/.bashrc:
stopwatch() {
perl -wE 'for (reverse 1..(shift)-1) {system q!clear!;open FIGLET,q!|figlet -f banner -c!;printf FIGLET "%2d:%02d",$_/60,$_%60;sleep 1}' "$1"
}source-ing ~/.bashrc抱怨如下:
当然,通常的壳包裹可以工作,但是这里我尝试让bash别名/函数调用珀尔。
必须有一种无需创建全新*.pl文件的方法。非常感谢!
发布于 2015-06-18 12:39:00
您也可以尝试以这种方式一起运行bash和perl脚本。而且,在你的例子中,-E是我怀疑的地方。perl -e总是工作,但perl -E在perl 5.8.8中不工作。
参见将perl与bash相结合的代码。
#!/bin/bash
# bash_test
echo "bash commands that you wish to write"
exit 0
# End of Bash part of the script.
# =======================================================
#!/usr/bin/perl
# This part of the script must be invoked with -x option.
print "here you can use your simple system() or exec() that you might wish to use right?";
# End of Perl part of the script.https://stackoverflow.com/questions/30914955
复制相似问题