1Copyright 2009 Kevin Ryde 2 3This file is part of constant-defer. 4 5constant-defer is free software; you can redistribute it and/or 6modify it under the terms of the GNU General Public License as 7published by the Free Software Foundation; either version 3, or (at 8your option) any later version. 9 10constant-defer is distributed in the hope that it will be 11useful, but WITHOUT ANY WARRANTY; without even the implied warranty of 12MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13General Public License for more details. 14 15You should have received a copy of the GNU General Public License along 16with constant-defer. If not, see <http://www.gnu.org/licenses/>. 17 18 19 20constant::defer makes subroutines similar to the builtin constant.pm, 21but with the value calculation deferred until the sub is actually run. 22 23 use constant::defer FOO => sub { calculate; 24 return $something }; 25 26This is handy for big or slow things only needed sometimes, or where 27at least the pain can be put off the point needed. 28 29Lazy or deferred calculations can be hidden behind a scalar variable 30too. The choice between a sub and a variable is a matter of style or 31personal preference. Both ways have advantages, see the 32constant::defer POD for some notes. 33 34The constant-defer home page is 35 36 http://user42.tuxfamily.org/constant-defer/index.html 37