in reply to How can I turn a string into a variable name?
Where do the 'options' come from? If they are from the command line use Getopt::Long. If they are derived internally (perhaps through a GUI or command line interface) then you could:
use strict; use warnings; my %options = map {$_ => 0} qw(one two three); $options{two} = 1; # Set in some unspecified place for my $option (grep {$options{$_}} keys %options) { print "Option '$option' was used\n"; }
Prints:
Option 'two' was used
|
|---|