Subject: | synopsis sample code error |
Date: | Thu, 06 Jan 2011 07:50:29 +1100 |
To: | bug-Language-Expr [...] rt.cpan.org |
From: | Kevin Ryde <user42 [...] zip.com.au> |
In Language::Expr 0.13 and recent debian i386 perl 5.10.1 I tried to run
the synopsis sample code of the Language::Expr pod, in foo.pl below, and
got an error
Undefined subroutine &Language::Expr::Compiler::Perl::sqr called at (eval 267) line 1.
Does the func() user function thingie only work for interpreted=>1, or
has to be a named perl function or something for it to work "compiled"?
(In case it helps, Test::Synopsis is a way to exercise synopsis code,
perhaps just as an "author" test.)
use 5.010;
use strict;
use warnings;
use Language::Expr;
my $le = new Language::Expr;
$le->var('a' => 1, 'b' => 2);
$le->func(sqr => sub { $_[0] ** 2 }, rand => sub {rand()});
# evaluate expression
say $le->eval('$a + sqr($b)'); # 5