summaryrefslogtreecommitdiff
path: root/fix_local_labels.pl
blob: d3258c76629dabcc80ec44cfde153e757422fd08 (plain)
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
use strict;
use warnings;

open(IN_FILE, $ARGV[0]);
open(OUT_FILE, ">", $ARGV[1]);

my @labels = ();

while (<IN_FILE>) {
	if ($_ =~ /^\.(.+):/) {
		push(@labels, $1);
	}
}

seek IN_FILE, 0, 0;

while (<IN_FILE>) {
	for (my $i = 0; $i < scalar(@labels); $i++) {
		my $find = quotemeta '.' . $labels[$i];
		my $replace = '$' . $labels[$i];
		$_ =~ s/$find/$replace/;
	}

	print OUT_FILE $_;
}

close(IN_FILE);
close(OUT_FILE);