我正在尝试使用 perl 脚本创建一个 excel 文件。
我按照教程编写了以下代码:
#!/usr/bin/perl
use strict;
use warnings;
use Excel::Writer::XLSX;
use Excel::Writer::XLSX::Utility;
my $workbook = Excel::Writer::XLSX->new( 'perl.xlsx' ); # Step 1
$worksheet = $workbook->add_worksheet('cc'); # Step 2
$worksheet->write( 'A1', 'Hi Excel!' );
但我收到以下错误:
Global symbol "$worksheet" requires explicit package name at test_excel.pl line 10.
Global symbol "$worksheet" requires explicit package name at test_excel.pl line 11.