如何將腳本的檔案名和輸入引數放入變數中?
所以它應該是這樣的:
# Start script as such: ./myscript.pl -d -s server1.domain
#!/usr/bin/perl
use strict;
use warnings;
my $call = some_command;
print $call; # Output: myscript.pl -d -s server1.domain
# OR ./myscript.pl -d -s server1.domain
# OR /path/to/myscript.pl -d -s server1.domain
嘗試這樣做__FILE__,$0但我似乎無法獲得變數中的輸入引數。
我在 AIX 機器上運行 v5.10.1。
uj5u.com熱心網友回復:
該程式及其引數分別位于$0和@ARGV中。
您可以使用 String::ShellQuote'sshell_quote從它們中形成命令列。
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/480264.html
標籤:perl
上一篇:你怎么匹配\'
