[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] Passing variables from applescript to perl.



Peter Gradwell <pjg7@aber.ac.uk> writes:
}Hi,
}
}I want to be able to plough through one of my mail boxes in eudora and pass
}the body to a perl routine, as a variable.

No need to involve Eudora in this.

}
}I can see how to do the applescript bit (i.e. going through all messages
}until the end of the mail box) but can't see how to assign things that
}applescript returns to a perl variable.

Gack.  Absolutely no need to use AppleScript, or even AppleEvents, at all.
MacPerl is *much*, *much* better at dealing with text files (or for that
matter most anything else) than AppleScript.  Eudora stores its mail in
standard Unix mbox format, and MailTools knows how to deal with that.

Here's a little test script that I use each time I want to test a new
MailTools distribution:

#!perl -w

use Mail::Util qw(read_mbox);
use Mail::Internet

@msg = read_mbox("The Black Pits:System Folder:Eudora Folder:In");
for $i (0..$#msg) {
$this = Mail::Internet->new($msg[$i]);
chomp($from = $this->head->get("From:"));
chomp($to = $this->head->get("To:"));
print "Message $i is from $from and to $to\n";


Mail::Internet also has a body() method, so you should be able to extract
the body with no trouble.  Hmm, let's see:

#!perl -w

use Mail::Util qw(read_mbox);
use Mail::Internet

@msg = read_mbox("The Black Pits:System Folder:Eudora Folder:In");
$this = Mail::Internet->new($msg[1]);
print @{$this->body};


correctly prints the body of message 1 in my In mailbox.  If you really
want the body in a single variable

$body = join("",@{$this->body});

should do the trick (and does).

}
[snip]

}
}Can anyone help as to how I should pass through variables.

Do it all in Perl.  You'll be much happier.

}
}Thanks
}
}Peter Gradwell.
}
}
}--
}Peter at Gradwell dot com
}mailto:Peter@Gradwell.com OR mailto:pjg7@aber.ac.uk
}
}VISIT it NOW! - http://www.irds.org/peter/
}NEW for the CLASSOF97 - http://www.loud-n-clear.com/gradwell/
}
}
}
}***** Want to unsubscribe from this list?
}***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch


---
Paul J. Schinder
NASA Goddard Space Flight Center
Code 693, Greenbelt, MD 20771
schinder@pjstoaster.pg.md.us



***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch