]> mj.ucw.cz Git - temple.git/commitdiff
Input and output should be in UTF-8
authorMartin Mares <mj@ucw.cz>
Wed, 23 Jan 2019 16:07:31 +0000 (17:07 +0100)
committerMartin Mares <mj@ucw.cz>
Wed, 23 Jan 2019 16:08:30 +0000 (17:08 +0100)
UCW/Temple.pm
temple

index 45c0ca37961003a6eac9fb18c3ad790b5391a05e..b8dd95d45f89f33f1e5177b12e0bee1bdb56210c 100644 (file)
@@ -5,6 +5,7 @@ package UCW::Temple;
 
 use strict;
 use warnings;
+use utf8;
 no strict 'vars';
 
 require Exporter;
@@ -210,11 +211,10 @@ sub parse_string($$) {
 sub parse_file($) {
        my ($name) = @_;
        add_depend($name);
-       my $fh = new IO::File $name;
-       error "Unable to open $name: $!" unless defined $fh;
+       open my $fh, '<:utf8', $name or error "Unable to open $name: $!";
        my $text;
        { local $/; undef $/; $text = <$fh>; }
-       undef $fh;
+       close $fh;
        parse_string($text, $name);
 }
 
diff --git a/temple b/temple
index 3f7a4d49539196a40da357ca17671a149af5bb10..f74543329a26d46a5b81e5e0cbc8f4d536a3f942 100755 (executable)
--- a/temple
+++ b/temple
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/perl -CSA
 # A really simple template engine
 # (c) 2004 Martin Mares <mj@ucw.cz>