Perl4caml allows you to use Perl code within Objective CAML (OCaml), thus neatly side-stepping the old problem with OCaml which was that it lacked a comprehensive set of libraries. Well now you can use any part of CPAN in your OCaml code.
Perl4caml has both a low-level interface to Perl, eg:
Perl.eval "$a = 3"; printf "$a contains %d\n" (Perl.int_of_sv (Perl.get_sv "a"));
and it contains high-level wrappers around some CPAN libraries (more to come later), eg:
open Pl_LWP_UserAgent
open Pl_HTTP_Request
(* Create the UserAgent object. *)
let ua = Pl_LWP_UserAgent.new_ ~env_proxy:true () in
(* Fetch the page. *)
let req = Pl_HTTP_Request.new_ "GET" ~uri:site () in
let res = ua#request req in
if not res#is_success then
failwith ("Error while fetching " ^ site ^ ": " ^ res#status_line);
There is complete ocamldoc documentation in the source distribution.
This library is distributed under the GNU Library General Public License with the special OCaml linking exception.
Perl4caml is also a part of Debian.
effective marketing for the web
Merjis specialises in innovative marketing,
accessibility, search engine optimisation (SEO),
and development for the web.