ЭЛЕКТРОННАЯ БИБЛИОТЕКА КОАПП |
Сборники Художественной, Технической, Справочной, Английской, Нормативной, Исторической, и др. литературы. |
evaleval string eval {block} Evaluates the expression or code in its argument at runtime as a separate
Perl program within the context of the larger script.
Any variable settings remain afterward, as do
any subroutine or format definitions. The code of the With The string form of$a = 3, $b = 4; $c = '$a * $b'; print (eval "$c"); # prints 12 eval is useful for executing strings produced
at runtime from standard or other dynamic input sources. If the string
produces an error, either from syntax or at runtime, the eval
exits with the undefined value and places the error in $@ .
If string is omitted, the operator evaluates $_ .The block form of As with any code in a block, a final semicolon is not required.eval { $a = 10; $b = 0; $c = $a / $b; # causes runtime error # trapped by eval }; print $@; # Prints "Illegal division by 0 at try.pl line 3" |