Thread externes File laden & variable ersetzen
(17 answers)
Opened by ack at 2008-05-20 09:30
Ich würde zu einem Templating-System raten. Z.B.
![]() Aber zu Deiner Frage: Code (perl): (dl
)
1 2 3 4 5 6 7 8 9 10 11 12 my $file = 'template.txt'; my $foo = 'footext'; my $content = ''; { local $/; open my $fh, '<', $file or die $!; $content = <$fh>; } $content =~ s/\$foo/$foo/g; print $content; statt dem Block kannst Du auch einfach das hier schreiben: Code (perl): (dl
)
my $content = do{ local (@ARGV,$/) = $file; <> }; OTRS-Erweiterungen (http://feature-addons.de/)
Frankfurt Perlmongers (http://frankfurt.pm/) -- Unterlagen OTRS-Workshop 2012: http://otrs.perl-services.de/workshop.html Perl-Entwicklung: http://perl-services.de/ |