in reply to Re: How to read flat file and execute a subroutine inside that flat file in my main program
in thread How to read flat file and execute a subroutine inside that flat file in my main program

Many thanks! It worked. Here is my sample code:

content of sample.txt:

1@@getTableID('public','t1')@@3
open FH, "sample.txt" or die $!; $str = <FH>; close FH; my @arr = split("@@",$str); sub getTableID($$) {return 100;} $subs{$arr[1]} = sub{getTableID($_[0],$_[1])}; my $val1 = $arr[0]; my $call = $arr[1]; my $func; if ($subs{$call}) { $func=$subs{$call}->(@arr1); print 'call:',$call.' func:'.$func."\n"; } else { print 'unknown sub:'.$call."\n"; }

output:

call:getTableID('public','t1') func:100
  • Comment on Re^2: How to read flat file and execute a subroutine inside that flat file in my main program
  • Select or Download Code