in reply to Extract Last Command Line Within script

Getopt::Long's GetOptions() sub modifies @ARGV, so you need to put this code before that call:
my $cmdline = "$0 @ARGV";

Note that $0 doesn't work on all platforms, and that shell interpolation is already done before the perl script starts, so you can't rely on this to be 100% accurate.