At 23:15 +0000 02.09.2001, John Delacour wrote:
>I've just discovered Andreas Marcel Riechert's TEC.pm which uses Apple
>Events to the TEC osax to convert between character sets, eg:
>
>
>use Mac::TEC;
>$_ = '³Ô²';
>$_ = Mac::TEC::ConvertText($_,'macintosh', 'windows-1252');
>print "$_$/";
>
>
>I have a couple of simple questions as a result, though not directly
>related to the module.
>
>1. Why in the above script and simliar scripts using different modules, is it
>necessary for me to repeat Mac::TEC in the third line when the module is
>already explicitly included?
Apparently, Mac::TEC does not export ConvertText. It needs to export it
for you to be able to access it without the full name. See the Exporter
docs for more information.
>2. The ConvertText subroutine needs to built an Apple Event and send it,
>so obviously there is a delay. However, suppose I were to loop through
>chunks in a file converting as I went, would the AE need to be compiled
>at every iteration or are all such things compiled once and for all at
>run time? In other words will I have to wait only before the first
>iteration and therafter be working with a faster, precompiled piece of
>kit?
That is up the module. There are ways to do it so it is only "compiled"
once. However, if the module uses raw Apple events; there is no
"compiling", per se, you are just making direct calls to the Apple Event
Manager. The compiling is essentially done when you compile the Perl
script. If it is using AppleScript, it can take a little while to compile
each time, in which case it would make sense to use Mac::OSA (or, more
easily, Mac::OSA::Simple) to compile it once and then execute repeatedly.
This may or may not work well, however, if the data is different each time.
I am not sure how to pass in different data to a compiled script like that.
>3. Would it be possible with pure MacPerl, without the intermediary of
>an osax and Apple Events to perform the same operations? I presume --
>nay I trust to HEAVEN! -- that the Text Encoding Converter and all
>Apple's other delaying ploys are redundant in MacOS X, but while I save
>up for my G4 and read all the OSX bug reports.....
I don't know. In theory, yes, it can be done, but I have never looked at
it. It might be a simple matter of making a little XS glue for it.
--
Chris Nandor [EMAIL PROTECTED] http://pudge.net/
Open Source Development Network [EMAIL PROTECTED] http://osdn.com/