use warnings;
use autodie;
+sub _utf8_slurp
+{
+ my $filename = shift;
+
+ open my $in, '<:encoding(utf-8)', $filename
+ or die "Cannot open '$filename' for slurping - $!";
+
+ local $/;
+ my $contents = <$in>;
+
+ close($in);
+
+ return $contents;
+}
+
use File::Basename qw / dirname /;
use File::Path qw / mkpath /;
use Getopt::Long qw/ GetOptions /;
open my $out, '>:encoding(utf-8)', $output_fn;
my $text = _utf8_slurp($input_fn);
-sub _utf8_slurp
+if ( ( $text =~ s#\Q[[cookiedir_placeholder]]\E#${cookiedir}#gms ) > 1 )
{
- my $filename = shift;
-
- open my $in, '<:encoding(utf8)', $filename
- or die "Cannot open '$filename' for slurping - $!";
-
- local $/;
- my $contents = <$in>;
-
- close($in);
-
- return $contents;
+ die "too many cookiedir_placeholder substitutions!";
+}
+if ( ( $text =~ s#\Q[[ocookiedir_placeholder]]\E#${ocookiedir}#gms ) > 1 )
+{
+ die "too many ocookiedir_placeholder substitutions!";
}
-
-die if ( $text =~ s#\Q[[cookiedir_placeholder]]\E#${cookiedir}#gms ) > 1;
-die if ( $text =~ s#\Q[[ocookiedir_placeholder]]\E#${ocookiedir}#gms ) > 1;
$out->print($text);
close($out);