Thread Einfügen eines Wertes in Zeile 3 einer Datei: ...bei einem CMS (12 answers)
Opened by cbxk1xg at 2004-07-03 19:28

Dubu
 2004-07-05 01:01
#3028 #3028
User since
2003-08-04
2145 Artikel
ModeratorIn + EditorIn

user image
[quote=cbxk1xg,03.07.2004, 22:03]Falls es jemanden interessiert... Ich habe eine, wie ich finde, performate und einfache Lösung gefunden.

Code (perl): (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
my $PMheader1 = "
<;!-- Template: $VAR{'template'} -->;;;;
<html";
my $PMheader2 = "
<;!-- Template: $VAR{'template'} -->;;;;
<HTML";

  print "Content-type: text/html

";

  my (@TEMPLATE) = @_;

  foreach $line (@TEMPLATE)
  {
    $line =~ s/\<html/$PMheader1/;
    $line =~ s/\<html/$PMheader2/;
    print "$line
";
  }
[/quote]
Nett. Du hast allerdings zwei Templates für "HTML" und "html", aber die Ersetzung geht nur auf die kleingeschriebene Variante (Tippfehler?). Und was ist mit Schreibweisen wie "HtMl"?


Vielleicht eher so:
Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
my $PMheader = "
<;!-- Template: $VAR{'template'} -->;;;
";

print "Content-type: text/html

";

my (@TEMPLATE) = @_;

foreach $line (@TEMPLATE)
{
    $line =~ s/(<html)/$PMheader1$1/i;
    print $line;
}
\n\n

<!--EDIT|Dubu|1089122446-->

View full thread Einfügen eines Wertes in Zeile 3 einer Datei: ...bei einem CMS