#!/usr/bin/perl -w

use v5.36;
use strict;

my %names;
my %vals;
while (<>) {
	chomp;
	my ($name, $rest) = split /:/;
	$names{$name} = $rest;
	$vals{$name} = 0+$rest if $rest =~ /\A\s*\d+\z/;
}

while (!defined $vals{root}) {
	for my $n (keys %names) {
		next if defined $vals{$n};
		my $e = $names{$n};
		my $d = 1;
		for my $v (keys %vals) {
			$e =~ s/$v/$vals{$v}/g;
		}
		next if $e =~ /[a-z]/;
		say "eval $e";
		eval "\$vals{$n} = $e";
		say "set \$vals{$n} to $vals{$n}" unless $@;
	}
	say " ================= ";
}

say $vals{root};
