How fast is an EVAL String
leif.eriksen at hpa.com.au
leif.eriksen at hpa.com.au
Mon Apr 26 20:46:17 CDT 2004
Just for completeness, I sent Scott a reference to the different ways
Perl processes
eval "string";
And
eval { block }
(from perldoc -f eval)
eval EXPR
eval BLOCK
In the first form, the return value of EXPR is parsed and
exe-
cuted as if it were a little Perl program. The value of
the
expression (which is itself determined within scalar
context)
is first parsed, and if there werenât any errors,
executed in
the lexical context of the current Perl program, so that
any
variable settings or subroutine and format definitions
remain
afterwards. Note that the value is parsed every time the
eval
executes. If EXPR is omitted, evaluates $_. This form
is typ-
ically used to delay parsing and subsequent execution of
the
text of EXPR until run time.
In the second form, the code within the BLOCK is parsed
only
once--at the same time the code surrounding the eval
itself was
parsed--and executed within the context of the current
Perl
program. This form is typically used to trap exceptions
more
efficiently than the first (see below), while also
providing
the benefit of checking the code within BLOCK at compile
time.
Which one you actually need depends on your requirements, but if eval
BLOCK works for you, use that.
Leif Eriksen
Snr Developer
ph +61 3 9217 5545
leif.eriksen at hpa.com.au
http://www.hpa.com.au <http://www.hpa.com.au>
**********************************************************************
IMPORTANT
The contents of this e-mail and its attachments are confidential and intended
solely for the use of the individual or entity to whom they are
addressed. If you received this e-mail in error, please notify
the HPA Postmaster, postmaster at hpa.com.au, then delete
the e-mail.
This footnote also confirms that this e-mail message has been swept for
the presence of computer viruses by MimeSweeper. Before opening or
using any attachments, check them for viruses and defects.
Our liability is limited to resupplying any affected attachments.
HPA collects personal information to provide and market our services.
For more information about use, disclosure and access see our Privacy
Policy at www.hpa.com.au
**********************************************************************
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.pm.org/archives/melbourne-pm/attachments/20040427/58a060ca/attachment-0001.htm
More information about the Melbourne-pm
mailing list