Re: [MacPerl] Re: problem with Japanese text

2003-03-26 Thread Chris Nandor
At 13:52 +0900 2003.03.27, Dan Kogai wrote:
>I wonder how many of you have ever tried 5.8 features such as Encode
>and PerlIO in MacPerl (besides "make test", of course).  I don't even
>lauch Classic these days...

Give me some examples to run and I can give it a shot.  :)

My greatest reason to run Classic is for Mac::Glue programs.  I have
everything I need for Mac::Glue ported, though, so I expect that to change
soon after I get back from vacation (I'll get to work on Mac::Glue after a
new release of Mac::Carbon, plus Mac::Apps::Launch and
Mac::AppleEvents::Simple, and probably a Bundle::Mac::Carbon ...).  But I
still plan on releasing MacPerl 5.8.x, which is mostly all there and
working now (I did a test build of the latest code a week or so ago).

-- 
Chris Nandor  [EMAIL PROTECTED]http://pudge.net/
Open Source Development Network[EMAIL PROTECTED] http://osdn.com/


Re: [MacPerl] Re: problem with Japanese text

2003-03-26 Thread Dan Kogai
On Thursday, Mar 27, 2003, at 01:31 Asia/Tokyo, Chris Nandor wrote:
Is there a reason for MacJPerl when MacPerl 5.8.x is released?
I thought none but the second thought;  The built-in text editor that 
many not support multibyte characters.  But even that is moot since 
there are many text editors which can use MacPerl, some of which even 
free (I use mi when I have to type in Japanese 
, free, perl-savvy, and 
supports all major Japanese encodings including UTF-8).

I wonder how many of you have ever tried 5.8 features such as Encode 
and PerlIO in MacPerl (besides "make test", of course).  I don't even 
lauch Classic these days...

Dan the ex-user of MacOS



Re: Another shell/GUI cooperation script

2003-03-26 Thread Ken Williams
On Wednesday, March 26, 2003, at 03:00  PM, Bruce Carter wrote:

Greetings Ken,

From a Perl newbie, and someone who just joined ths list, how does one 
learn about embedding AppleScript in Perl scripts?  Thanks very much 
for any pointers.
You can start by looking at
  http://search.cpan.org/author/DSUGAL/Mac-AppleScript/AppleScript.pm
That's the module I used in the example I posted to the list.

 -Ken



Another shell/GUI cooperation script

2003-03-26 Thread Ken Williams
Hey,

I've saved the following script as ~/bin/attach .  It lets me create a 
new Mail message from the command line with a given file as an 
attachment.  For example:

 % attach foo/bar/baz.doc

Here's the script:


#!/usr/bin/perl
use Mac::AppleScript qw(RunAppleScript);
use File::Spec;
my $file = shift or die "No file specified";
$file = File::Spec->rel2abs($file);
RunAppleScript(<
tell application "Mail"
  set newMessage to make new outgoing message
  tell newMessage
set visible to true
tell content
  make new attachment with properties {file name:"$file"} at after 
the last character
end tell
  end tell
  activate
end tell
END


I created this by modifying Apple's "/Library/Scripts/Mail 
Scripts/Create New Message.scpt" . Hope it's useful to someone else.

Chris, would it be fun/possible to convert all that applescript to perl?

 -Ken



Re: [MacPerl] Re: problem with Japanese text

2003-03-26 Thread Chris Nandor
In article <[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] (Robin) wrote:

> MacPerl per se historically has not been aware of locale outside of 
> ascii defined ones (not sure about the latest version). Which is why of 
> course there is MacJPerl.
> 
> http://world.std.com/~habilis/macjperl

Is there a reason for MacJPerl when MacPerl 5.8.x is released?

-- 
Chris Nandor  [EMAIL PROTECTED]http://pudge.net/
Open Source Development Network[EMAIL PROTECTED] http://osdn.com/


Re: Perl grep from AppleScript

2003-03-26 Thread Chris Nandor
In article <[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] (Christopher Stone) wrote:

> I used to use the RegEx osax for a huge number of tasks, but it hasn't been 
> ported to X nor will it ever be.
> 
> So, that being the case I have to break down and learn Perl...  :)
> 
> This rank newbie needs a template for using perl grep from AppleScript.

FWIW: you use grep in perl to loop over the elements of a list, performing 
some action (usually matching) against each one, and returning the ones that 
match.  So you probably don't mean "grep" here.


> What I want to do is provide input from an AppleScript variable; grab the 
> pattern I want with perl; and output to an AppleScript variable.

   do shell script "perl -e '$x = shift; $x =~ /(.pat.)/; print $1' spatter"
   > "spatt"

Hope that helps,

-- 
Chris Nandor  [EMAIL PROTECTED]http://pudge.net/
Open Source Development Network[EMAIL PROTECTED] http://osdn.com/


Perl grep from AppleScript

2003-03-26 Thread Christopher Stone
Greetings,

I'm a recent convert to Mac OS X.

I used to use the RegEx osax for a huge number of tasks, but it hasn't been ported to 
X nor will it ever be.

So, that being the case I have to break down and learn Perl...  :)

This rank newbie needs a template for using perl grep from AppleScript.

What I want to do is provide input from an AppleScript variable; grab the pattern I 
want with perl; and output to an AppleScript variable.

If someone could help me out I'd be most appreciative; the unixy bits have still got 
me a trifle flummoxed.

Thanks.
  

Best Regards,

Chris


Re: [MacPerl] Re: problem with Japanese text

2003-03-26 Thread Robin
While I realise this is diverging slightly from the original posting, I 
think some background info is useful for dealing with Japanese text. 
There are several text encoding formats - the most widly used being 
ShiftJIS and EUC-JP. Without going into too many details, ShiftJIS 
encoding was created by Microsoft to its usual exacting (lack of) 
standards, which makes it ticklish to deal with, so in the past when 
processing Japanese text, Japanese perlers used a four step conversion 
solution:

(1) input converted from Shift_JIS to EUC_JP
(2) EUC_JP encoded data processed
(3) EUC_JP data converted back to Shift_JIS
(4) output
perl 5.8.0 has built in Unicode support, however the same 4 step 
process is still required for Shift-JIS data

(1) input converted from Shift_JIS to UTF8 (unicode)
(2)  UTF8 encoded data processed
(3) UTF8 data converted back to Shift_JIS
(4) output
MacPerl per se historically has not been aware of locale outside of 
ascii defined ones (not sure about the latest version). Which is why of 
course there is MacJPerl.

http://world.std.com/~habilis/macjperl



HTH

Robin





On Wednesday, March 19, 2003, at 05:58  am, Scott R. Godin wrote:

Jon Reinsch wrote:

I use a simple MacPerl program to archive my email: I save each 
message to
a text file, then run the program to append the messages to a text 
file in
date/time order. Omitting some details, the heart of the program is 
just:

open (inhandle,"$infilename"))
{
while()
{ print $outhandle $_; }
}
My problem is that some of my email contains Japanese text. I'm 
running OS
9.2.1 with the Japanese Language Kit installed. But when Japanese text
goes through the program it comes out as garbage like
"bÉvÇ•ñŽéwÇ…ÇÝǻLJÇÃÉiÉrÉQÅ[É^Å". Obviously the encoding is being 
lost,
but I don't have the slightest idea how to fix this. Is there a 
module out
there that would provide a simple answer to this problem? Maybe it's 
just
a fantasy, but I'm hoping for something simple like
print $outhandle convertJapaneseText($_);


This might seem very simple but have you looked into

use locale

at all ? try looking at perldoc perllocale for some informative text.

dunno if this will help but it's where my instincts pointed me...