Reputation: 1651
I have this perl script and it takes in arguments using the getoption package.
Is there 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
Upvotes: 1
Views: 393
Reputation: 63902
or you can simply
my $full;
BEGIN { $full = "$0 @ARGV" }
#
print "log: $full\n";
$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";
Upvotes: 5
Reputation: 46183
Use $0
and @ARGV
together:
my $full_command = join(' ', $0, @ARGV);
Upvotes: 7