How can a condition inside if block be changed based on the variable value in Perl?
Let's say if $platform value is "window", then evaluation statement of "if ()" must be different, and if $platform value is Linux, evaluation statement of "if()" must be different.
Code Snippet:
my $command;
if ( $platform eq "lnx86" ){
$command='( $kk eq "qw" ) ';
}
else{
$command='( $kk eq "we" ) ';
}
my $kk="we";
my $platform=wint; ## Passed from outside as a command line parameter
if ( $command ) { ## (Line 13) Here, I want the value of $command to be replaced and if() evaluate the condition after replacement of the variable. Currently, it checks that the $command value is substituted and thus returns TRUE or FALSE. But, desire is that the value of $command must be substituted, and the substituted value must be evaluated.
print "def\n";
}
else{
print "nothing";
}
Requirement:
Here, ( on line 13) I want the value of $command to be replaced and if() evaluate the condition after replacement of the variable. Currently, it checks that the $command value is substituted and thus returns TRUE or FALSE. But, desire is that the value of $command must be substituted, and the the substituted value must be evaluated.
Please do provide a suitable assistance.
Thanks in advance!
Aucun commentaire:
Enregistrer un commentaire