开发者

perl, saving the command line option

开发者 https://www.devze.com 2023-03-12 08:36 出处:网络
I have this perl script and it takes in arguments using the getoption package. Is th开发者_如何学Goere an easy way to document what was the exact command the user used to execute?

I have this perl script and it takes in arguments using the getoption package.

Is th开发者_如何学Goere an easy way to document what was the exact command the user used to execute?

I would like to document into a log file.

Gordon


Use $0 and @ARGV together:

my $full_command = join(' ', $0, @ARGV);


or you can simply

my $full;
BEGIN { $full = "$0 @ARGV" }
#
print "log: $full\n";

form the perlvar

$LIST_SEPARATOR
$"

When an array or an array slice is interpolated into a double-quoted string or a similar context such as /.../ , its elements are separated by this value. Default is a space. For example, this:

print "The array is: @array\n";

is equivalent to this:

print "The array is: " . join($", @array) . "\n";
0

精彩评论

暂无评论...
验证码 换一张
取 消