使用strict和warnings获取列表错误



在同一目录中的文件列表上运行Perl脚本可以执行更改列表,这对我来说很好,但目前,我必须在sun Solaris 10上使用该脚本,但我收到了以下警告:

在/usr/perl5/5.8.4/lib/sun4-solaris-64int/Convert/ASN1/_decode.pm第58行使用未初始化的长度值。

在/usr/perl5/5.8.4/lib/sun4-solaris-64int/Convert/ASN1/_encode.pm第60行的串联(.(或字符串中使用未初始化的值。

搜索后,我发现了use strictuse warnings之类的内容,但当我进行更改时,它返回以下错误:

全局符号"@files"需要位于的显式包名称/5th_edit.pl

第14行。全局符号"@dirs"要求在./5th_edit.pl第15行。

#!/usr/bin/perl -w
use strict;
use warnings;
use TAP3::Tap3edit;
use Data::Dumper;

printDir(".");
sub printDir{
opendir(DIR, $_[0]);
local(@files);
local(@dirs);
(@files) = readdir(DIR);
foreach $file (@files) {
if (-f $file and substr($file,0,2) eq "CD" ) {

my $tap3 = TAP3::Tap3edit->new;
my $tap_file = $file;
$tap3->decode($tap_file)  or  die $tap3->error; 
my $struct=$tap3->structure;
my $Tracker = $struct->{'transferBatch'};
if (defined $Tracker){
my $rectag = $struct->{'transferBatch'}->{'networkInfo'}->{'recEntityInfo'};
map { $_->{'recEntityType'} = 4 if ( $_->{'recEntityType'} > 6) } @$rectag;
my $calleventtag = $struct->{'transferBatch'}->{'callEventDetails'};
my @indexes = reverse (grep { exists $calleventtag->[$_]->{'supplServiceEvent'} } 0..$#$calleventtag);
my $sup_event_cnt = $#indexes;
foreach my $index (@indexes)
{
splice (@$calleventtag , $index,1);
}
my $total_events_cnt = $struct->{'transferBatch'}->{'auditControlInfo'}->{'callEventDetailsCount'};
$struct->{'transferBatch'}->{'auditControlInfo'}->{'callEventDetailsCount'} = $total_events_cnt - $sup_event_cnt-1;
if ( exists $struct->{'transferBatch'}->{'batchControlInfo'}->{'operatorSpecInformation'} )
{
delete $struct->{'transferBatch'}->{'batchControlInfo'}->{'operatorSpecInformation'};
}
if ( exists $struct->{'transferBatch'}->{'auditControlInfo'}->{'operatorSpecInformation'} )
{
delete $struct->{'transferBatch'}->{'auditControlInfo'}->{'operatorSpecInformation'};
}
my $key;
# Will scan all the calls for MOC's and GPRS.
foreach $key ( @{$struct->{'transferBatch'}->{'callEventDetails'} } ) {
foreach ( keys %{$key} ) {
if ( $_ eq "mobileOriginatedCall" )
{
if ( exists $calleventtag->[$_]->{'mobileOriginatedCall'}->{'basicCallInformation'}->{'destinationNetwork'} )
{
delete $calleventtag->[$_]->{'mobileOriginatedCall'}->{'basicCallInformation'}->{'destinationNetwork'};
}
if ( exists $calleventtag->[$_]->{'mobileOriginatedCall'}->{'basicCallInformation'}->{'chargeableSubscriber'}->{'simChargeableSubscriber'}->{'msisdn'} 
&& $calleventtag->[$_]->{'mobileOriginatedCall'}->{'basicCallInformation'}->{'chargeableSubscriber'}->{'simChargeableSubscriber'}->{'msisdn'} !~ m/^1299/ 
)
{
delete $calleventtag->[$_]->{'mobileOriginatedCall'}->{'basicCallInformation'}->{'chargeableSubscriber'}->{'simChargeableSubscriber'}->{'msisdn'};
}
if ( exists $calleventtag->[$_]->{'mobileOriginatedCall'}->{'camelServiceUsed'}  
&& $calleventtag->[$_]->{'mobileOriginatedCall'}->{'camelServiceUsed'}->{'camelServiceKey'} != 80
)
{
delete $calleventtag->[$_]->{'mobileOriginatedCall'}->{'camelServiceUsed'};
}
}
if ( $_ eq "gprsCall" )
{
if ( exists $calleventtag->[$_]->{'gprsCall'}->{'gprsBasicCallInformation'}->{'gprsDestination'}->{'accessPointNameOI'} )
{
delete $calleventtag->[$_]->{'gprsCall'}->{'gprsBasicCallInformation'}->{'gprsDestination'}->{'accessPointNameOI'};
}
}
}
}

$tap3->encode("$tap_file")  or  die $tap3->error; 
}    
}
} 
closedir(DIR);
}

my而不是local初始化@files@dirs变量。

my @files;
my @dirs;

在Perl中,my和local之间有什么区别?

最新更新