use strict; use warnings; sub getTableID($$) {return 100;} my @arr; while(){ chomp; push(@arr, $_); } foreach my $line(@arr) { my @arr1 = split(",",$line,2); my $val1 = $arr1[0]; # add the & to make sure it is thought of as a subroutine; my $call='&'.$arr1[1]; print $call."\n"; my $func = eval $call; if ($@) { print 'Error:'.$@."\n"; } else { print 'func:'.$func."\n"; } } __DATA__ 1,getTableID('DBO','Table2') 2,getTableID('DBO','Table2') 3,putTableID('DBO','Table2')