in reply to regexp matching issue
If i understood your question correctly, is this you want?
$input = $ARGV[0]; undef $/; $str = <DATA>; while ($str =~ /(template?\d+)[^}]+}/gsi) { $hash{$1} = $&; } %temp = ('test1' => "template2", 'test2' => "template3", 'test1,test2' + => "template1"); @a= keys %hash; @m= grep /^$temp{$input}$/, @a; print "$m"; if (@m) { print "$hash{$m[0]}" ; } else { print "$hash{'template4'}"; } #print "$_\t$hash{$_}\n" for keys %hash; __DATA__ template1(test1,test2) { variable_1 : input; index_1(" 1.0, 2.0"); index_2(" 1.0, 2.0"); } template2(test1,!test2) { variable_1 : output; index_1(" 1.0, 2.0"); } template3(!test1,test2) { variable_1 : time; index_2(" 1.0, 2.0"); } template4(!test1,!test2) { variable_1 : time; index_1(" 1.0, 2.0"); }
updated:
Prasad
|
|---|