in reply to Re^3: Using a sting with a variable name
in thread Using a sting with a variable name

it's a trivial test to add.

One catch, using the following data, it'll say $var exists. But that's probably good enough.
@var = qw( a b c ); $var2 = undef; $one = '$var'; # Exists! $two = '$var2'; # Exists

Replies are listed 'Best First'.
Re^5: Using a sting with a variable name
by JavaFan (Canon) on May 11, 2009 at 15:21 UTC
    Really? That's not what I get (nor expect):
    use 5.010; @var = qw (a b c); $var2 = undef; $one = '$var'; $two = '$var2'; if (defined ${"${\substr $one, 1}"}) { say '$var exists'; } else { say '$var does not exist'; } __END__ $var does not exist
      You're still only checking whether the variable is defined or not. The data I gave was for after you made the change you said would check for existence.
        You really think the answer will change after adding a test for defined $one? Last time I looked, '$var' is a defined value.