- publishing free software manuals
Perl Language Reference Manual
by Larry Wall and others
Paperback (6"x9"), 724 pages
ISBN 9781906966027
RRP £29.95 ($39.95)

Sales of this book support The Perl Foundation! Get a printed copy>>>

7.34 Constant Folding

Like C, Perl does a certain amount of expression evaluation at compile time whenever it determines that all arguments to an operator are static and have no side effects. In particular, string concatenation happens at compile time between literals that don't do variable substitution. Backslash interpolation also happens at compile time. You can say

'Now is the time for all' . "\n" .
    'good men to come to.'

and this all reduces to one string internally. Likewise, if you say

foreach $file (@filenames) {
    if (-s $file > 5 + 100 * 2**16) {  }
}

the compiler will precompute the number which that expression represents so that the interpreter won't have to.

ISBN 9781906966027Perl Language Reference ManualSee the print edition