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

MacPerl-Digest V1 #7




MacPerl-Digest        Thursday, March 11 1999        Volume 01 : Number 007



[MacPerl] File::Spec;
Re: [MacPerl] File::Spec;
[MacPerl] Mac::Glue etc.
[MacPerl] Elementary Question
[MacPerl] Division by zero error from a regex
Re: [MacPerl] Division by zero error from a regex
Re: [MacPerl] Elementary Question
Re: [MacPerl] Division by zero error from a regex
Re: [MacPerl] Division by zero error from a regex
Re: [MacPerl] Elementary Question
Re: [MacPerl] Mac::TextEdit
Re: [MacPerl] Mac::TextEdit
[MacPerl] as2p

----------------------------------------------------------------------

Date: Tue, 9 Mar 1999 17:12:39 +0100
From: Hartmut Kern <kern@kern-e-p.com>
Subject: [MacPerl] File::Spec;

Hello,
I've got the following problem:
# Can't locate File/Spec.pm
Where is it?

My macperl version is - I think - the latest: 5.2.0r4 from 17Apr.98.

I tried to test libwww with the t-files coming with the UNIX - distribution.
Most of them work. But there is one producing this error message:

# Can't locate File/Spec.pm in @INC.
File 'bla:bla:MacPerl Ÿ:Neu 3.1999 install  Perl Module:t
libwww-perl:local:get.t'; Line 6

(get.t - if you are interested in what I am testing)

This is the head of the .t skript:
#
# Test retrieving a file with a 'file://' URL,
#

# First locate some suitable tmp-dir.  We need an absolute path.
use File::Spec;
use URI::file;
.
.
.

What can I do? Where can I get spec.pm for MacPerl?

I try to write perl skripts for crossplatform use. So I think it may be
useful  for the future.

Sorry for my pure English.

Hartmut Kern

                               -***-
KERN elektronisches Publizieren
Leuschner Damm 31
10999 Berlin

t: +49 (0) 30 614 25 72
f: +49 (0) 30 614 25 99

e-mail: mailto://kern@kern-e-p.com
www: http://www.kern-ep.de

                               -***-



===== Want to unsubscribe from this list?
===== Send mail with body "unsubscribe" to macperl-request@macperl.org

------------------------------

Date: Tue, 9 Mar 1999 11:42:10 -0500
From: Chris Nandor <pudge@pobox.com>
Subject: Re: [MacPerl] File::Spec;

At 11.12 -0500 1999.03.09, Hartmut Kern wrote:
>Hello,
>I've got the following problem:
># Can't locate File/Spec.pm
>Where is it?

On CPAN.  It was not included in perl until 5.004_05 (or 5.005, depending
on your whether you are referring to a sequence of events temporally or by
version, but I digress).  MacPerl 5.2.0r4, the latest version of MacPerl,
is only up to 5.004.

>What can I do? Where can I get spec.pm for MacPerl?

Spec, not spec.  Case matters.  And you can get it off CPAN.  See
www.cpan.org for details.  You can also download my cpan-mac stuff, which
includes tools for using CPAN (and includes File::Spec, too).

>I try to write perl skripts for crossplatform use. So I think it may be
>useful  for the future.

Absolutely.  It is a good thing.

- --
Chris Nandor          mailto:pudge@pobox.com         http://pudge.net/
%PGPKey = ('B76E72AD', [1024, '0824090B CE73CA10  1FF77F13 8180B6B6'])

===== Want to unsubscribe from this list?
===== Send mail with body "unsubscribe" to macperl-request@macperl.org

------------------------------

Date: Tue, 9 Mar 1999 12:33:15 -0500
From: Chris Nandor <pudge@pobox.com>
Subject: [MacPerl] Mac::Glue etc.

I am working on Mac::Glue these days, and I will be discussing it over on
macperl-modules, so if you are interested and are not on the list, please
join.  Also, when I find some cool new OSA or AE things, I might be
mentioning them on the macperl-toolbox list (like a first go at a droplet
to save MacPerl scripts as compiled AppleScripts that I sent over this
morning).

- --
Chris Nandor          mailto:pudge@pobox.com         http://pudge.net/
%PGPKey = ('B76E72AD', [1024, '0824090B CE73CA10  1FF77F13 8180B6B6'])

===== Want to unsubscribe from this list?
===== Send mail with body "unsubscribe" to macperl-request@macperl.org

------------------------------

Date: Tue, 9 Mar 1999 12:35:16 -0500
From: "Noe Dinnerstein:  President, BodhiSoftWare" <norbu108@tuna.net>
Subject: [MacPerl] Elementary Question

I'm a rank beginner at MacPerl.  I'm going through the MacPerl book and
have a problem.
given the following script:


!#perl

open ( IN,   'README') or die ("Input File open failed\n");
open ( OUT,   '>>Report') or die ("Output File open failed\n");

print ("starting loop\n");

 while ($line = <IN>) {
	print OUT ($line);
 }

print  ("end of loop\n");

close (IN);
close (OUT);

*************************

I get the following output:

starting loop
end of loop

But the output file is empty.   The input file exists, yet this behaviour
looks like the input file is empty (not the case).   What is the obvious
thing I'm missing?


	Noe

	          \\\
	         (@v@)  W
	          (  O )  //
	            |  | //
	          /  ? |/
	         //     |
	         |||     \
	         M| /\ |
	            ||   ||
	            ||   ||
	            LL  LL
		



===== Want to unsubscribe from this list?
===== Send mail with body "unsubscribe" to macperl-request@macperl.org

------------------------------

Date: Tue, 9 Mar 1999 12:08:59 -0600 (CST)
From: Chris Blanford <blanf001@tc.umn.edu>
Subject: [MacPerl] Division by zero error from a regex

Hello all -

I'm trying to process a text file of Current Contents citations with
MacPerl. I'd appreciate any help here.

I'm working in "file slurp" mode. I'm trying to remove the extra authors
to convert lines like these:
Authors: Occelli ML
Authors: Biz S
Authors: Auroux A
Authors: Ray GJ

to:
Authors: Occelli ML; Biz S; Auroux A; Ray GJ

I'm trying to use this bit of code to set a placeholder for the first
author, remove the extra authors and replace the placeholder with
"Author: ". I'm operating on $_.

s/(Abstract: .*?)Author:/$1\nAUTHORXX/g;
s/ Author:/;/go;
s/AUTHORXX/Author: //go;

It works as expected if the final substitution is commented out, but it
chokes on that last line with:
# Illegal division by zero, <INF> chunk 1.

Thoughts, please.

Chris

- -----------------------------------------------------
Christopher F. Blanford   V: 612/626-8036
180 Kolthoff Hall         F: 612/626-7541
207 Pleasant St SE        E: blanf001@tc.umn.edu
Minneapolis MN 55455      W: http://umn.edu/~blanf001
- -----------------------------------------------------

PGP keyID: 356CC429  http://pgp.ai.mit.edu/



===== Want to unsubscribe from this list?
===== Send mail with body "unsubscribe" to macperl-request@macperl.org

------------------------------

Date: Tue, 9 Mar 1999 10:22:33 -0800
From: Rich Morin <rdm@cfcl.com>
Subject: Re: [MacPerl] Division by zero error from a regex

At 10:08 AM -0800 3/9/99, Chris Blanford wrote:

  s/AUTHORXX/Author: //go;
                      ^

Why is the second slash here?  Did you perhaps mean to say:

    s/AUTHORXX/Author: /go;

- -r
- --
Rich Morin:          rdm@cfcl.com, +1 650-873-7841, http://www.ptf.com/~rdm
Prime Time Freeware: info@ptf.com, +1 408-433-9662, http://www.ptf.com
MacPerl: http://www.ptf.com/macperl,   http://www.ptf.com/ptf/products/MPPE
MkLinux: http://www.mklinux.apple.com, http://www.ptf.com/ptf/products/MKLP

===== Want to unsubscribe from this list?
===== Send mail with body "unsubscribe" to macperl-request@macperl.org

------------------------------

Date: Tue, 9 Mar 1999 14:20:31 -0400 (AST)
From: Arved Sandstrom <Arved_37@chebucto.ns.ca>
Subject: Re: [MacPerl] Elementary Question

On Tue, 9 Mar 1999, Noe Dinnerstein:  President, BodhiSoftWare wrote:

> !#perl
> 
> open ( IN,   'README') or die ("Input File open failed\n");

You might want to switch the ! and # in the first line so you have
'#!perl'.

I'm not even sure why this works for you. Under ActiveState perl, the ! is
negating the first open(), and the script reports that the open() failed.
Note that the #perl chunk has just become a very ordinary comment, which
extends to the end of the line, but the expression that the ! is working
on goes to the first ;.

Arved



===== Want to unsubscribe from this list?
===== Send mail with body "unsubscribe" to macperl-request@macperl.org

------------------------------

Date: Tue, 9 Mar 1999 14:28:26 -0400 (AST)
From: Arved Sandstrom <Arved_37@chebucto.ns.ca>
Subject: Re: [MacPerl] Division by zero error from a regex

On Tue, 9 Mar 1999, Chris Blanford wrote:

> I'm trying to process a text file of Current Contents citations with
> MacPerl. I'd appreciate any help here.
> 
> I'm working in "file slurp" mode. I'm trying to remove the extra authors
> to convert lines like these:
> Authors: Occelli ML
> Authors: Biz S
> Authors: Auroux A
> Authors: Ray GJ
> 
> to:
> Authors: Occelli ML; Biz S; Auroux A; Ray GJ
> 
My thoughts are, that there's a time and a place for "file slurp". :-)

In this case, to keep the logic simple, I'd loop over each input line, and
if it has the string "Authors:" at the start, I'd extract the name and
concatenate it to the variable "Authors: Name1; Name2; ...".

You may be getting some dubious gains in speed (although I haven't
checked), but IMHO you're obscuring the logic of a very simple task.

Arved



===== Want to unsubscribe from this list?
===== Send mail with body "unsubscribe" to macperl-request@macperl.org

------------------------------

Date: Tue, 9 Mar 1999 12:32:55 -0600 (CST)
From: Chris Blanford <blanf001@tc.umn.edu>
Subject: Re: [MacPerl] Division by zero error from a regex

D'oh. That was it. Thanks.

On Tue, 9 Mar 1999, Rich Morin wrote:

> At 10:08 AM -0800 3/9/99, Chris Blanford wrote:
> 
>   s/AUTHORXX/Author: //go;
>                       ^
> 
> Why is the second slash here?  Did you perhaps mean to say:
> 
>     s/AUTHORXX/Author: /go;
> 
> -r


===== Want to unsubscribe from this list?
===== Send mail with body "unsubscribe" to macperl-request@macperl.org

------------------------------

Date: Tue, 9 Mar 1999 15:47:39 -0500 (EST)
From: rjk@linguist.dartmouth.edu (Ronald J. Kimball)
Subject: Re: [MacPerl] Elementary Question

Noe Dinnerstein:  President, BodhiSoftWare wrote:
> 
> I'm a rank beginner at MacPerl.  I'm going through the MacPerl book and
> have a problem.
> given the following script:
> 
> 
> !#perl
> 
> open ( IN,   'README') or die ("Input File open failed\n");
> open ( OUT,   '>>Report') or die ("Output File open failed\n");
> 
> print ("starting loop\n");
> 
>  while ($line = <IN>) {
> 	print OUT ($line);
>  }
> 
> print  ("end of loop\n");
> 
> close (IN);
> close (OUT);
> 
> *************************
> 
> I get the following output:
> 
> starting loop
> end of loop
> 
> But the output file is empty.   The input file exists, yet this behaviour
> looks like the input file is empty (not the case).   What is the obvious
> thing I'm missing?
> 

Where did the README file come from?
Might all the README file's contents be in the resource fork?

Ronald

===== Want to unsubscribe from this list?
===== Send mail with body "unsubscribe" to macperl-request@macperl.org

------------------------------

Date: Tue, 09 Mar 1999 16:23:50 -0500
From: "Quentin Smith" <macmania@bit-net.com>
Subject: Re: [MacPerl] Mac::TextEdit

I would think that, but I found a script that "use"s Mac::TextEdit. It is 
also mentioned in the excellent book MacPerl:Power and Ease.

- -----BEGIN GEEK CODE BLOCK----
Version: 3.12
GCS d s:+ !a C++++ U*+++ P++++ L+ E-- W+++ N++ o+ K- w--- O? M++ V? PS PE-
Y-- PGP++ t+ 5 X R tv++ b+++ D I- D? G! e h! r
- -----END GEEK CODE BLOCK-----

- ----------
>From: larryat@cts.com (Larry F. Allen-Tonar)
>To: "Quentin Smith" <macmania@bit-net.com>
>Cc: MacPerl List <mac-perl@iis.ee.ethz.ch>
>Subject: Re: [MacPerl] Mac::TextEdit
>Date: Tue, Mar 9, 1999, 3:04 AM
>

> Quentin,
>
> I suspect that you obtain the hooks by requiring Gestalt.pm
> (point your shuck at ...:appl Ÿ:MacPerl Ÿ:lib:Mac:Gestalt.pm).
>
> Use the standard Mac OS documentation to understand how to use it.
>
>>I would like to know if anyone knows where I can obtain Mac::TextEdit. I
>>have seen many references to it, but I can not find it in the MacPerl 5.020
>>distribution or in CPAN.
>
> --
> Regards, Larry F. Allen-Tonar        (larryat@cts.com) +1 760/746-6464 (voice)
>          Principal Designer                              +1 760/746-0766 (FAX,
>          P.O. Box 463072                                         upon request)
>          Escondido, CA  92046-3072

===== Want to unsubscribe from this list?
===== Send mail with body "unsubscribe" to macperl-request@macperl.org

------------------------------

Date: Tue, 9 Mar 1999 17:00:51 -0500
From: Chris Nandor <pudge@pobox.com>
Subject: Re: [MacPerl] Mac::TextEdit

At 16.23 -0500 1999.03.09, Quentin Smith wrote:
>I would think that, but I found a script that "use"s Mac::TextEdit. It is
>also mentioned in the excellent book MacPerl:Power and Ease.

There is such a module, though I don't think it was mentioned in the book.
Matthias Neeracher wrote it, and I don't know where it is available from.

- --
Chris Nandor          mailto:pudge@pobox.com         http://pudge.net/
%PGPKey = ('B76E72AD', [1024, '0824090B CE73CA10  1FF77F13 8180B6B6'])

===== Want to unsubscribe from this list?
===== Send mail with body "unsubscribe" to macperl-request@macperl.org

------------------------------

Date: Wed, 10 Mar 1999 07:59:40 -0500
From: Chris Nandor <pudge@pobox.com>
Subject: [MacPerl] as2p

Requires a new Mac::OSA::Simple 0.10, on CPAN.

Will make all perl scripts dropped on it into compiled AppleScripts.  Lets
you select to either embed perl script text in the compiled AppleScript, or
to just make AppleScript contain alias to the script.  Both have their
advantages: one method lets you have one file and easily distribute it.
The other lets you easily edit the script since you only have a pointer to
it in the AppleScript.

This has only been tested by me, so caveat scriptor.  Please let me know
how it works for you.

Why a compiled AppleScript?  So you can put it in your scripts menu in
programs like BBEdit and ircle and OSA Menu.

#!perl -w
# as2p :)
# pudge@pobox.com
# 1999.03.10

use File::Basename;
use Mac::OSA::Simple 0.10;
use Mac::Resources;
use Mac::Memory;
use strict;

sub fix_text (\$);

die "Need at least one Perl script!\n" unless @ARGV;

# select which type of compiled script you want ... hardcode this
# if you like:  Text = 1, Alias = 0
my $switch = MacPerl::Answer('For all scripts, save script text or ' .
     'alias to script on disk?', 'Text', 'Alias');

# drop as many scripts as you can handle
for my $f (@ARGV) {
    my($comp, $data, $res, $script, $len, $file, $dir, $text);

    # get AppleScript text
    $text = ($switch ? get_text($f) : get_alias($f))
        or (warn("No text for '$f'") && next);

    # get new name of file
    ($file, $dir) = fileparse($f, '\..+$');
    $file = "$dir$file.scr";

    # get compiled AppleScript and stick it in a new handle
    $comp = compile_applescript($text);
    $data = $comp->compiled or (warn("No data for '$f'") && next);
    $len = length($data);
    $script = NewHandle($len);
    $script->set(0, $len, $data);

    # create new compiled AppleScript file (will fail if file exists)
    CreateResFile($file) or (warn("Can't create '$file': $^E") && next);
    MacPerl::SetFileInfo('ToyS', 'osas', $file);

    # put data into new file
    $res = FSpOpenResFile $file, 0
        or (warn("Can't open '$file': $^E") && next);
    AddResource($script, 'scpt', 128, 'MacPerl Script')
        or (warn("Can't add resource to '$file': $^E") && next);
    UpdateResFile($res)
        or (warn("Can't update resources for '$file': $^E") && next);
    CloseResFile($res);
}

sub get_alias {
    my($file, $text) = @_;

    fix_text($file);

    $text = qq'tell application "MacPerl" to Do Script alias "$file"';

    $text;
}

sub get_text {
    my($file, $script, $text) = @_;
    local($/, *F);

    open F, $file or die "Can't open '$file': $!";
    $script = <F>;
    close F or die "Can't close '$file': $!";

    fix_text($script);

    $text = <<EOS;
tell application "MacPerl" to Do Script "
$script
"
EOS

    $text;
}

sub fix_text (\$) {
    my $text = shift;

    # more to do than just fix " marks and \ ?
    $$text =~ s/\\/\\\\/g;
    $$text =~ s/"/\\"/g;

    1;
}

__END__

- --
Chris Nandor          mailto:pudge@pobox.com         http://pudge.net/
%PGPKey = ('B76E72AD', [1024, '0824090B CE73CA10  1FF77F13 8180B6B6'])

===== Want to unsubscribe from this list?
===== Send mail with body "unsubscribe" to macperl-request@macperl.org

------------------------------

End of MacPerl-Digest V1 #7
***************************


==== Want to unsubscribe from this list?
==== Send mail with body "unsubscribe" to
==== macperl-digest-request@macperl.org