in reply to how to read perl variable from a line read from a file
Hello Bharath666, and welcome to the Monastery!
As parv says, one approach is to use eval:
my ($VAR1, $VAR2);
my $INST = 'C';
if (/ ^ ([^=]*?) = (.*) $ /x)
my ($lhs, $rhs) = ($1, $2);
eval '$' . $lhs . ' = "' . $rhs . '";';
warn $@ if $@;
say for $VAR1, $VAR2;
22:54 >perl 513_SoPW.pl
The problem with this ‘solution’ is that the code is tightly-bound to the exact form of the input data, making it brittle and inflexible. I have to say, you will be better-off re-examining the broader problems your code is addressing, and then re-thinking your general strategy.
Hope that helps,