Journal rjw57's Journal: More perl...
More wodges of code now. This nicely shows the autoboxing of Scalars and actually does something useful that you
namespace PerlEmbedExamples {
using System;
using Perl;
class IMAPExample {
public static void Main(string[] args) {
Console.WriteLine("Embedding Perl within Mono - IMAP Example");
Console.WriteLine("(C) 2004 Rich Wareham\n");
Interpreter interpreter = new Perl.Interpreter();
interpreter.Embed();
try {
interpreter.Require("Mail::IMAPClient");
Scalar client = interpreter.CallClassMethod("Mail::IMAPClient", "new",
"Server", "charon",
"User", "rjw57",
"Password", "XXXXXXXXX");
if(!client) {
Console.WriteLine("Could not log into server.");
return;
}
Scalar[] folders = interpreter.CallMethod(client, "subscribed",
Interpreter.CallFlags.ArrayContext);
Console.WriteLine("Subscribed to {0} folders:", folders.Length);
foreach(string folder in folders) {
Console.WriteLine(" -> {0}", folder);
}
} catch ( PerlException e ) {
Console.WriteLine("Error was thrown: {0}", e.Message);
}
}
}
}