So jetzt funktioniert alles.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
sub tmpl {
   my $usrid = get_my_userid();
   my $text;
   local $/;
   local *D;
   my ($dat, $hashref) = @_;
   open(D, $_[0]) || die $!;
      $text = <D>;
   close(D);
   $hashref->{sid} = $sessionid unless $hashref->{sid};
   $hashref->{username} = $usrid;
   chop($text);
   $text =~ s{ %% ( .*? ) %% }
      { exists( $hashref->{$1} )
         ? $hashref->{$1}
         : ""
      }gsex;
   print header(-type => "text/html", -charset => 'ISO-8859-1') if $hashref->{header} == 1;
   return $text;
} 
noch ne andere Frage: Ist es vielleicht ratsamer, für das CGI-Modul ein Objekt zu machen?
Wenn ja, dann our ?