prog.pl 第 24 行语法错误,但我不知道为什么

syntax error at prog.pl line 24, But I do not know why

我是这里的初学者,我认为一切都很顺利,直到我收到此错误消息:第 24 行 prog.pl 语法错误,靠近“SignificanceofPlate” 由于编译错误,prog.pl 的执行中止。 有人可以帮忙解释一下第 24 行有什么问题吗?如果第 24 行有问题,那么所有包含“SignificanceofPlate”的行不应该有问题吗?他们都是一样的。 24号线是阿拉斯加下的第一个“SignificanceofPlate”。我认为它太长了所以我缩短了名称,但我仍然 运行 遇到同样的问题。

#!/usr/bin/perl
# Perl Assignment - Hash of Hashes
# J Student

# Teams using a Hash of Hashes



# Alaska      1967     The Last Frontier
# Massachusetts  1928     No Motto
# New York   1966      New York
#Vermont     1960      See Vermont
# Mississippi     2019     No Motto #Driver's county of residence replaces motto. I do not approve of this.

# I have created the following array:

@teams = ("Alaska", "New Mexico", "New York", "Vermont" , "Hawaii");

# and the following Hash of Hashes:

%myTeams = ( "Alaska" => { bestYear => 1967,
                                   Motto => "The Last Frontier",
                                   Color=> "Yellow on Blue"
                                   SignificanceofPlate=> "Totem pole on plate"
                                   priceOfplate=> "0+"
                                  },
              "Massachusetts" => { bestYear => 1928,
                                    Motto => "Massachusetts did not have mottos on their plates until 1990's"
                                   Color=> "White on Green"
                                   SignificanceofPlate=>"Bad omen plate; 1st time any state put a picture of anything on a plate and it was a fish. But this fish is swimming away from the word Mass. 1928, fisherman did not catch any fishes. Fisherman blamed the DMV"
                                   priceOfplate=>"200+"
                                    
                                  },
              "New York" => { bestYear => 1966,
                                    Motto => "New York",
                                    Color=> "Yellow on Blue"
                                    SignificanceofPlate=>"Nothing, I just simply love the color combination"
                                    priceOfplate=>"30.00+"
                                    
                                  },
                    "Vermont" => { bestYear => 1961,
                                    Motto => "See Vermont",
                                    Color=>"White on Green"
                                    SignificanceofPlate=> "Nothing, But it's a switch up from regular color license plates"
                                    priceOfplate=> "20.00+"
                                    
                                  },
                       "Mississippi" => { bestYear => 2019,
                                    Motto => "No motto", #Though someone will say, it's the 'In God We Trust' Plate
                                    Color=> Blue on Gold
                                    SignificanceofPlate=> "This is a very controversial plate because it feature the words, 'In God We Trust' on the plate" #It's mind boggling to me why it's controversial because Mississippi is a highly religious state. Possibly the most religious state.
                                    priceOfplate=> "8.99" #This is very tricky because these plates are new so not many people are selling them. But I imagine they'll be expensive throughout the years. I have mine already :)
                                  },

);

# To print out sorted Team information in the Hash of Hashes (ascending order):

print ("\n\nMy Team - sorted by Team Name ascending:\n\n");

printf("%-20s \t%-6s \t%-10s \t%-25s \n", "Team", "Year", "Owner", "Leader");

@sortedKeys = sort (@teams);

for $teamName (@sortedKeys) {
    $bestYear = $myTeams{$teamName}{'bestYear'};
    $Motto = $myTeams{$teamName}{'Motto'};
    $Color = $myTeams{$teamName}{'Color'};
    $SignificanceofPlate = $myTeams{$teamName}{'SignificanceofPlate'};
    $priceOfplate = $myTeams{$teamName}{'priceOfplate'};

    printf("%-20s \t%-6i \t%-10s \t%-25s \n", $teamName, $bestYear, $Motto, $Color, $SignificanceofPlate, $priceOfplate);
    print "\n";
}

# To print out sorted Team information in the Hash of Hashes (descending order):

print ("\n\My Team - sorted by Team Name decending:\n\n");

printf("%-20s \t%-6s \t%-10s \t%-25s \n", "Team", "Year", "Motto", "Color", "Significance", "Price");

@reverseKeys = reverse (@sortedKeys);

for $teamName (@reverseKeys) {
    $bestYear = $myTeams{$teamName}{'bestYear'};
    $Motto = $myTeams{$teamName}{'Motto'};
    $Color = $myTeams{$teamName}{'Color'};
    $Significanceofplate = $myTeams{$teamName}{'SignificanceofPlate'};
    $priceOfplate = $myTeams{$teamName}{'priceOfplate'};
    
    printf("%-20s \t%-6i \t%-10s \t%-25s \n", $teamName, $bestYear, $Motto, $Color, $SignificanceofPlate,  $priceOfplate );
    print "\n";
}

print "\n\nHTML Page containing information on my Team:\n\n";

print "<html>\n";
print "<head>\n";
print "<title>My Team</title>";
print "</head>\n";
print "<body>\n";
print "<H1>License Plates</H1>\n";
print "<table border=1>\n";
print "<tr><th>Team</th><th>Year</th><th>Motto</th><th>Color<tr><th>Significance</th><th>Price</th></tr>\n";
for $teamName (sort keys %myTeams ) {
    $bestYear = $myTeams{$teamName}{'bestYear'};
    $Motto = $myTeams{$teamName}{'Motto'};
    $Color = $myTeams{$teamName}{'Color'};
    $SignificanceofPlate = $myTeams{$teamName}{'SignificanceofPlate'};
    $priceOfplate = $myTeams{$teamName}{'priceOfplate'};

   print "<tr><th>Team</th><th>Year</th><th>Motto</th><th>Color<tr><th>Significance</th><th>Price</th></tr>\n";
}
print "</table>\n";
print "</body>\n";
print "</html>\n";

标记<表示缺失,(其他块也缺失,

"Alaska" => { bestYear => 1967,
              Motto => "The Last Frontier",
              Color=> "Yellow on Blue"                    <
              SignificanceofPlate=> "Totem pole on plate" <
              priceOfplate=> "0+"
            },

Mississippi 块之后删除 , 因为没有任何块跟随

            "Mississippi" => { bestYear => 2019,
                               Motto => "No motto", #Though someone will say, it's the 'In God We Trust' Plate
                               Color=> Blue on Gold
                               SignificanceofPlate=> "This is a very controversial plate because it feature the words, 'In God We Trust' on the plate" #It's mind boggling to me why it's controversial because Mississippi is a highly religious state. Possibly the most religious state.
                                priceOfplate=> "8.99" #This is very tricky because these plates are new so not many people are selling them. But I imagine they'll be expensive throughout the years. I have mine already :)
                             },        <-- remove , as no blocks follow
);

Polar Bear 编辑的最后一个区块

print 
"<html>
    <head>
        <title>My Team</title>
    </head>
    <body>
        <H1>License Plates</H1>
         <table border=1>
              <tr>
                  <th>Team</th>
                  <th>Year</th>
                  <th>Motto</th>
                  <th>Color</th> 
                  <th>Significance</th>
                  <th>Price</th>
             </tr>
";

for $teamName (sort keys %myTeams ) {
    $bestYear = $myTeams{$teamName}{'bestYear'};
    $Motto = $myTeams{$teamName}{'Motto'};
    $Color = $myTeams{$teamName}{'Color'};
    $SignificanceofPlate = $myTeams{$teamName}{'SignificanceofPlate'};
    $priceOfplate = $myTeams{$teamName}{'priceOfplate'};

    print 
"            <tr>
                   <td>$teamName</td>
                   <td>$bestYear</td>
                   <td>$Motto</td>
                   <td>$Color</td>
                   <td>$SignificanceofPlate</td>
                   <td>$priceOfplate</td>
             </tr>
";
}

print "
        </table>
    </body>
</html>
";

前一行 (26) 缺少一个逗号。在以下行中多次重复相同的错误。

你也应该

use warnings;

获取有关代码中潜在问题的更多信息。