-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtemplate.pl
More file actions
44 lines (31 loc) · 681 Bytes
/
template.pl
File metadata and controls
44 lines (31 loc) · 681 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
use strict;
use warnings;
use MIME::Base64;
my @replacements =
(
["//!SPIRAX", "assets/spirax.woff", 1],
["//!SCP", "assets/source_code_pro.woff", 1],
["//!AVATAR", "assets/avatar.png", 1],
);
sub slurp($)
{
open (my $fh, "<", shift) or die;
local $/;
my $str = <$fh>;
close $fh;
return $str;
}
my $input = slurp $ARGV[0];
for my $rule (@replacements)
{
my ($match, $file, $base64) = @$rule;
my $replacement = slurp $file;
if ($base64)
{
$replacement = encode_base64 $replacement, "";
}
$input =~ s/\Q$match/$replacement/g;
}
open (my $output, ">", $ARGV[1]) or die;
print $output $input;
close $output;