Perl value lookup and replace

Hi,

I have an input file and a config file which I need to lookup values in using Perl:

Input file:

ID, Value
COMP0,0
COMP1,1
COMP2,2
COMP3,3
COMP4,3
COMP5,5

Config file:

ID, Operation
COMP0,((@COMP1@ + @COMP2@ + @COMP3@) / @COMP4@) + @COMP5@

Expected output:

ID, Value
COMP0,7 # This is ((1 + 2 + 3) / 3) + 5
COMP1,1
COMP2,2
COMP3,3
COMP4,3
COMP5,5

The config file contains two columns (comma separated). The first column contains the ID and the second column the operation.
For each ID in the Input file, I need to check if it's in the config file, and if it's found then evaluate the operation in the second column by substituting all @ID@ values with the actual values of those ID's.

I have both files stored in array's, and I can combine the 2 files but I'm stuck doing the substitution here. Any help would be appreciated.

Thanks

EDIT: I think I found the solution myself:

       $operation =~ s/@([^@]*)@/$lookupvalue{$1}/g;
       print eval($operation) . "\n";