I want the output to be dependent on the contents of a regex-captured variable $1. This variable will contain a number (as a string) either of one digit, or more than one digit. I need to make a conditional statement that is evaluated within quotes, so I was hoping to use ${ } as a block instead of a variable call. something like:$outputarray->[$level] = eval "\"$interpol\"";
except that, clearly, if this worked, I wouldn't be here. The logic of this algorithm is separate from the parser that contains the eval. I cannot commingle the two. Due to the constraints of the system, my only option for basing a condition on this temporary variable is to feed that logic through this eval.${if($1 =~ /\d{2,}/){return "driving a vehicle ${1} lbs over the weigh +t limit";}elsif($1 =~ /\d{1}/){return "driving a vehicle $1 tons over + the weight limit";}}
I'm not asking whether this is the right way to do it, it seems pretty clear it isn't. I'm just asking if it's *possible* ^_^ (and no, I can't change the structure of the eval. The \"s stay right where they are. The only thing I can modify, at least for the purposes of this experiment, is the string contained by $interpol).
Any thoughts?
In reply to logic within interpolation by karrakis
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |