use Math::Algebra::Symbols my ($foo) = symbols(qw(foo)); my $result = ($foo * 2) + ($foo * 3); print "$result\n";