Wrappers now automatically 'use' modules.
[perl4caml.git] / examples / test.ml
index 56d2bfa..99bcfd4 100644 (file)
@@ -1,16 +1,18 @@
 (* Simple test of the API.
  * Copyright (C) 2003 Merjis Ltd.
- * $Id: test.ml,v 1.1 2003-10-12 11:56:27 rich Exp $
+ * $Id: test.ml,v 1.3 2003-10-15 16:51:12 rich Exp $
  *)
 
 open Printf
 
-let () =
-  (* Arguments passed to the Perl "command line". Loads [test.pl] *)
-  let args = [| ""; "-wT"; "examples/test.pl" |] in
+(* XXX Hack to workaround some sort of linking bug in OCaml. Without this
+ * the Perl module isn't initialized and this code crashes.
+ *)
+let f = Pl_Net_Google.may
 
-  (* Create the Perl interpreter. *)
-  let pl = Perl.create ~args () in
+let () =
+  (* Load "test.pl". *)
+  Perl.eval "require 'examples/test.pl'";
 
   (* Call some subroutines in [test.pl]. *)
   let sv = Perl.call ~fn:"return_one" [] in
@@ -49,4 +51,4 @@ let () =
   printf "TestClass.foo is %d\n" (Perl.int_of_sv sv); flush stdout;
 
   (* Destroy the interpreter. *)
-  Perl.destroy pl
+  Perl.destroy (Perl.current_interpreter ())