in reply to How can I turn a string into a variable name?

In theory, you could write

print "Option $string was used\n" if ( eval "\$$string" );

But, as already said, don't.  eval in this context is definitely worse than using a hash, in almost every regard.

Replies are listed 'Best First'.
Re^2: How can I turn a string into a variable name?
by ikegami (Patriarch) on Jan 09, 2010 at 20:08 UTC
    Why use eval to do
    if do { no strict 'refs'; $$string };
      Why use eval

      ...because the OP used lexical variables.  Symbolic references ($$string) only work with package variables.