use strict; use File::Copy qw(move); unless ($ARGV[0]) { print "Usage: update_map.pl \n"; exit; } my $backup = $ARGV[0] . ".bkp"; if (-f $backup) { print "$backup exists. Remove to continue\n"; exit; } move ($ARGV[0], $backup) or die "Move to $backup failed: $!"; my ($input, $output, @data); open ($input, "<", $backup) or die "Can't open $backup: $!"; open ($output, ">", $ARGV[0]) or die "Can't $ARGV[0]: $!"; push @data, $_ while (); sub trim { my $string = shift; $string =~ s!^simulation/templates/!!; $string =~ s!\n$!!; return $string; } sub change { my $template = shift; foreach my $s (@data) { my ($old, $new) = split (":", $s); return trim ($new) if trim ($old) eq $template; } return ""; } while (my $str = <$input>) { if ($str =~ /