Pits: Substitution in href-tag

Beitrag lesen

hi folks,

Folgendes Problem: Ich lese die gesamte HTML aus einem File (in @data_file), welches ich dann zeilenweise verarbeite. Kommt in einer Zeile der Begriff "~link~" vor so soll er durch bereits eingelesene Variablen ersetzt werden. Diese befinden sich in @db_content.

So hab ich das codiert (wobei hier noch Leerzeichen durch _ ersetzt werden):

foreach $i (@data_file) {
  if ($_ =~ m/~link~/) {
    $temp = $db_content[$i];
    $db_content[$i] =~ s/ /_/;
    $_ =~ s/~link~/<a href="/$db_content[$i].pl" target="_self">$temp</a>/;
    $i++;
  }
  print $_;
}

So sieht die Apache-Fehlermeldung aus:
[Fri Mar 09 13:44:13 2007] [error] [client 127.0.0.1] Premature end of script headers: home.pl
[Fri Mar 09 13:44:13 2007] [error] [client 127.0.0.1] Scalar found where operator expected at D:/web/Fust_AG/cgi-bin/home.pl line 60, near "s/\~link\~/<a href="/$db_content"\r
[Fri Mar 09 13:44:13 2007] [error] [client 127.0.0.1] String found where operator expected at D:/web/Fust_AG/cgi-bin/home.pl line 60, near "pl" target=""\r
[Fri Mar 09 13:44:13 2007] [error] [client 127.0.0.1] Bareword found where operator expected at D:/web/Fust_AG/cgi-bin/home.pl line 60, near "" target="_self"\r
[Fri Mar 09 13:44:13 2007] [error] [client 127.0.0.1] \t(Missing operator before _self?)\r
[Fri Mar 09 13:44:13 2007] [error] [client 127.0.0.1] String found where operator expected at D:/web/Fust_AG/cgi-bin/home.pl line 60, at end of line\r
[Fri Mar 09 13:44:13 2007] [error] [client 127.0.0.1] \t(Missing semicolon on previous line?)\r
[Fri Mar 09 13:44:13 2007] [error] [client 127.0.0.1] syntax error at D:/web/Fust_AG/cgi-bin/home.pl line 60, near "s/\~link\~/<a href="/$db_content"\r
[Fri Mar 09 13:44:13 2007] [error] [client 127.0.0.1] Can't find string terminator '"' anywhere before EOF at D:/web/Fust_AG/cgi-bin/home.pl line 60.\r

Kann mir jemand helfen??

Thanx