我有这个脚本:
#!/usr/bin/perl
$LOGFILE = "Soccer.txt";
open(LOGFILE) or die("Could not open log file.");
foreach $line (<LOGFILE>) {
chomp $line;
($hour, $match, $idh, $back1, $lay1, $idd, $backx, $layx, $ida, $back2, $lay2) = split(/\s*,\s*/,$line);
$match =~ s/^(\d{2}):(\d{2}) //g; #/ # fix highlighting
($hteam,$ateam) = split(/\s*§\s*/,$match,2);
$hteam = get_name($hteam);
$ateam = get_name($ateam);
$match = "$hteam - $ateam";
$foo=qq($hour "$match" $idh $back1 $lay1 $idd $backx $layx $ida $back2 $lay2 \n) ;
print $foo;
}
sub get_name {
# Return the full name for the team, if it exists, otherwise return the original
my %alias = (
"Aalen" => "Vfr Aalen",
"Accrington" => "Accrington Stanley",
"Accrington St" => "Accrington Stanley",
"Adelaide Utd" => "Adelaide United Fc"
);
return $alias{$_[0]} // $_[0];
}
这个scrpit在我的系统中非常完美:
perl, v5.10.1 (*) built for i686-linux-gnu-thread-multi
现在我想在另一个系统中运行它:
perl, v5.8.8 built for x86_64-linux-thread-multi
当我尝试运行它时,我收到此错误:
Search pattern not terminated at ./scriptbd.robot.pl line 458.
为什么我收到错误?
答案 0 :(得分:9)
return $alias{$_[0]} // $_[0];
//
operator was added in 5.10。要使它在早期的Perls上运行,请重写它:
return (defined $alias{$_[0]}) ? $alias{$_[0]} : $_[0];