in reply to Re^7: Using a sting with a variable name
in thread Using a sting with a variable name
Sorry, I used the wrong var name. What I meant is that fixing the failing case below and will cause the third to fail.
uuse strict; use warnings; no strict 'vars'; use Test::More tests => 3; sub var_exists { my ($var) = @_; return defined ${substr $var, 1}; } { no warnings 'once'; $var1 = 'a'; $var2 = undef; @var3 = qw( a b c ); } ok(var_exists('$var1'), 'var1'); ok(var_exists('$var2'), 'var2'); ok(!var_exists('$var3'), 'var3');
1..3 ok 1 - var1 not ok 2 - var2 # Failed test 'var2' # at a.pl line 20. ok 3 - var3 # Looks like you failed 1 test of 3.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^9: Using a sting with a variable name
by JavaFan (Canon) on May 11, 2009 at 17:57 UTC | |
by ikegami (Patriarch) on May 11, 2009 at 18:32 UTC | |
by JavaFan (Canon) on May 11, 2009 at 19:07 UTC | |
by ikegami (Patriarch) on May 11, 2009 at 20:01 UTC | |
by JavaFan (Canon) on May 11, 2009 at 20:23 UTC | |
|