Next | Making Programs Faster | 96 |
#!/usr/bin/perl -w use Test::More 'no_plan'; my $code = q{"x" . "y"}; is(eval $code , 'xy', "string eval"); is(eval{$code}, 'xy', "block eval");
Let's make sure those evals are doing what we thought:
ok 1 - string eval not ok 2 - block eval # Failed test (evaltest.pl at line 6) # got: '"x" . "y"' # expected: 'xy' 1..2 # Looks like you failed 1 tests of 2.
How about that
The "block eval" is not actually eval-ing the code
eval {$code} is not analogous to eval $code
It is analogous to eval '$code'
Next | Copyright © 2003 M. J. Dominus |