【发布时间】:2012-02-10 08:48:53
【问题描述】:
我有这个脚本:
#!/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];
}
这个脚本在我的系统中完美运行:
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.
为什么我会收到错误消息?
【问题讨论】:
-
您发布的程序中没有 458 行。 :)
-
如果将 '§' 替换为标准 ASCII 字符会怎样?
-
你真的应该以
use strict; use warnings;开始你的脚本
标签: perl