Piers Harding > Inline-BC-0.07 > Inline::BC

Download:
Inline-BC-0.07.tar.gz

Dependencies

Annotate this POD

CPAN RT

Open  1
View/Report Bugs
Module Version: 0.07   Source   Latest Release: Inline-BC-0.08

NAME ^

Inline::BC - Inline ILSM for bc the arbitrary precision math Language

SYNOPSIS ^

  use Inline BC;
  print x(int(rand(time())));
  __DATA__
  __BC__
  define x(a){
    scale = 20;
    return (a*3.456789);
  }

DESCRIPTION ^

Inline::BC is an ILSM (Inline Support Language Module ) for Gnu bc, the arbitrary precision numeric processing language. Inline::BC - like other ILSMs - allows you compile (well - render to byte code ), and run Gnu bc code within your Perl program.

From the Gnu BC README:

bc is an arbitrary precision numeric processing language. Syntax is similar to C, but differs in many substantial areas. It supports interactive execution of statements. bc is a utility included in the POSIX P1003.2/D11 draft standard.

This version was written to be a POSIX compliant bc processor with several extensions to the draft standard. Option flags are available to cause warning or rejection of the extensions to the POSIX standard. For those who want only POSIX bc with no extensions, a grammar is provided for exactly the language described in the POSIX document. The grammar (sbc.y) comes from the POSIX document. The Makefile contains rules to make sbc. (for Standard BC)

"end of quote"

Further documentation about Gnu bc can be found at: http://www.gnu.org/software/bc/bc.html http://www.gnu.org/manual/bc/html_mono/bc.html

one thing to note is that you should be careful with setting the global bc parameters like ibase, obase, scale etc. You should not set these in the global code - instead, set them in each function, to avoid the chaos that would follow.

Looking at the test suite - there are examples of several different ways of invoking Inline::BC:

(1) code in the DATA statement use Inline BC; print x(4) == 5.3 ? "ok 2\n" : "not ok 2\n"; __DATA__ __BC__ define x (a) { scale = 20 return (a * 1.5); }

(2) inline code with here document use Inline BC => <<'END_BC'; define z (a, b) { scale = 6 t = a * .357; t = b / t; return ( t ); } END_BC print z(4, 7) > 4 ? "ok 3\n" : "not ok 3\n";

(3) code in an external file use Inline BC => './tools/test.dat'; print aa() =~ /[0\n]/s ? "ok 4\n" : "not ok 4\n";

VERSION ^

very new

AUTHOR ^

Piers Harding - piers@cpan.org

SEE ALSO ^

man bc - perldoc Inline

COPYRIGHT ^

Copyright (c) 2002, Piers Harding. All Rights Reserved. This module is free software. It may be used, redistributed and/or modified under the same terms as Perl itself.

syntax highlighting: