On October 12, 1999 at 19:27, zheng wang wrote:
Is it possible to get some example scripts that call mhonarc? I am trying
to automatically convert the mail from petidomo into html file.
Will you being calling MHonArc within Perl programs? Is so, you
can invoke MHonArc directly without using system(). For example,
look at the source code for "mhonarc":
unshift(@INC, 'lib'); # Should I leave this line in?
require 'mhamain.pl' || die qq/ERROR: Unable to require "mhamain.pl"\n/;
mhonarc::process_input() ? exit(0) : exit($mhonarc::CODE);
In sum, to call MHonArc with Perl programs, you do the following
to initialize the MHonArc library:
Note, you may need set @INC properly if mhamain.pl is not in perl's
default search path.
Once that is done, you can invoke mhonarc::process_input() to
process data. You can pass arguments to mhonarc::process_input()
as you would pass arguments on the command-line. For example:
The difference is that the arguments are passed as a Perl list.
This is actually more secure than using system() since no shell
interpretation is done (unless of cource you invoke system with
a list argument).
mhonarc::process_input() will return a true value if everything went
ok. Else, it returns a false value, and exit code can be
retrieved with $mhonarc::CODE;
This embedded Perl approach allows to call MHonArc on multiple
archives (*in sequence*) without the overhead of forking off a
process each time.
For more complex examples of the MHonArc API, see the various mha-*
Someday I will get around to documenting the API.