在perl中使用pod2usage时出现编译错误

在perl中使用pod2usage时出现编译错误,perl,Perl,我有一个文件,它接受一个文件作为参数,并对其执行一些操作 #!/usr/bin/perl use strict; use warnings; use Date::Format; use Pod::Usage; ################### #USAGE ################### =head1 SYNOPSIS perl my-file.pl <log file name> Options: -help

我有一个文件,它接受一个文件作为参数,并对其执行一些操作

#!/usr/bin/perl    
use strict;
use warnings;
use Date::Format;
use Pod::Usage;

###################
#USAGE
###################

=head1 SYNOPSIS

perl my-file.pl <log file name>

     Options:
       -help            Prints usage synopsis of this program.
       -man         Man page for this program.

Use option "-man" for extended usage help.

=head1 ARGUMENTS 

=over 1

=item 1 Log File Name

Enter name of the log file. This is a required argument.

=cut

print "\n\n";
GetOptions('help|?' => \$help, man => \$man) or pod2usage(2);
pod2usage(1) if $help;
pod2usage(-verbose => 2) if $man;
pod2usage("$0: Insufficient arguments given. Please see the usage below...")  if (@ARGV == 0);  

my $logfile = $ARGV[0];    
my $cmd;
my $n;
$cmd = q(awk '!/Jobs still running./' $logfile > temp.txt && mv temp.txt $logfile);
$n = system($cmd)
.

您已打开,但未能声明变量。你通常都是这样做的。给你


我建议您选择或的副本。

您会遇到错误,因为您在代码中使用了
使用strict
,但您没有声明任何变量

要理解变量声明,请阅读本教程

Global symbol "$help" requires explicit package name at mv-workitem-LogWatcher.pl line 33.
Global symbol "$man" requires explicit package name at mv-workitem-LogWatcher.pl line 33.
Global symbol "$help" requires explicit package name at mv-workitem-LogWatcher.pl line 34.
Global symbol "$man" requires explicit package name at mv-workitem-LogWatcher.pl line 35.
my-file.pl had compilation errors