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

[MacPerl Announcement] [FAQ] MacPerl FAQ



People have asked about the FAQ, so here it is (I hope that's OK with the
maintainers):

About the MacPerl FAQ

Version and Date information:

This is version 2.4 which was last revised September 15, 1996. Changes since
prior release:

   * CPAN now mirrors the FAQ in the correct place.
   * Clarified the operation of 8-bit character pattern matching.

See below for locations of the current FAQ.

The MacPerl FAQ is currently being edited and maintained by Bob Dalgleish
and Bob Wilkinson. Contact them for editorial or publication information.
The initial version of the FAQ was prepared by Hal Wine. The current outline
and a lot of the useful words in this edition were prepared by Hal, as well.

This FAQ is intended as a supplement to the main Perl FAQ , and does not
replace it.

Where to get the most recent MacPerl release:

The best way to get official releases of the MacPerl application or tool or
this FAQ is to use the Comprehensive Perl Archive Network.

   * Use FTP to get the site registry and find the repository site nearest
     you. Save this information for later use when you want to get files. It
     saves wear and tear on the 'net and administrators everywhere.
   * Use a Web browser to search for the file to download. This URL will
     find a (relatively local) mirror site to get your file. This URL uses a
     magic process to refer you to a nearby FTP site. There is also a form
     that will identify the most recent versions of released files and give
     you the URL without the search.

Where to get the most recent FAQ:

The most recent copy of the FAQ is available as MacPerlFAQ.html and
MacPerlFAQ.txt.

They are mirrored from MacPerlFAQ.html and MacPerlFAQ.txt, but this web-site
has some name registration problems.

Versions of the FAQ can be retrieved by e-mail. Send e-mail to
MacPerl@dtor.com with a subject of either:

    get FAQ

for the text version or

    get FAQ.html

for the html version.

What the FAQ covers:

The MacPerl FAQ tries to answer simple questions that are unique to the
various versions of MacPerl. For more complex questions, pointers to more
detailed information may be given.

The MacPerl FAQ also contains information on some unique applications of
MacPerl. However, pointers to other information are more likely for these
topics.

Finally, the MacPerl FAQ contains information useful in porting Perl scripts
to and from the Unix environment.

What the FAQ doesn't cover:

The MacPerl FAQ does not cover basic Perl questions. Nor does it cover basic
Macintosh programming information. It certainly doesn't cover details of WWW
CGI programming! This is handled slightly different on the Mac than on other
platforms, and pointers are provided for detailed information.

The MacPerl FAQ is also not a tutorial. Nor is it a 100% correct authority
on anything! However, we ask your indulgence by sending comments,
clarifications, and revisions to one or both of the editors.

How the FAQ is organized:

This FAQ is organized from general information through more specific
information. A given topic is covered in the most general location possible.

Both Perl version 4 and 5 have been ported to the Mac. Much of the
information in this FAQ is not unique to the Perl version being used.

Where there is a distinction or discrepancy between the versions, the
applicable version will be mentioned. The most frequent difference is how
package qualifications are made. In Perl4, a variable in a package was
entered as $Package'variable. In Perl5, it is entered as $Package::variable,
although the old form is acceptable.

The major emphasis of the FAQ has moved to MacPerl 5, so the new package
syntax will be used.

Where possible, the users of MacPerl should upgrade to MacPerl5, since its
extensibility and generality are very much enhanced. Perl4 scripts will run
almost unimpeded under Perl5, but you can easily check for problems by
setting the -w switch to flag common errors. The reference file
perltraps.html in the release describes common problems.
----------------------------------------------------------------------------
Table of Contents

   * 1) General Questions
        o 1.1) What's the most recent version of MacPerl?
             + 1.1.1) Perl 5
             + 1.1.2) Perl 4
        o 1.2) How do I install MacPerl?
             + 1.2.1) Transferring the files:
             + 1.2.2) How do I unpack the stuff I got?
        o 1.3) What Macs does MacPerl run on?
        o 1.4) Other MacPerl resources:
             + 1.4.1) Is there an email list for MacPerl?
             + 1.4.2) What other useful resources are there?
   * 2) MacPerl Differences
        o 2.1) What are the differences in functions on MacPerl?
        o 2.2) Compatability with Unix Perl
             + 2.2.1) Why does source preprocessing (-P) not work?
             + 2.2.2) How do I open a pipe both to and from a command?
             + 2.2.3) Why do %ENV changes not pass to processes that I
               start?
             + 2.2.4) Why don't backticks work as they do on Unix?
        o 2.3) MacOS file system issues
             + 2.3.1) How do I request an input or output file under
               MacPerl?
             + 2.3.2) Why can't I detect aliases in my script?
             + 2.3.3) How do I pass environment variables to my script?
             + 2.3.4) How do I perform globbing in MacPerl?
        o 2.4) Application additions
             + 2.4.1) package MacPerl
             + 2.4.2) Macintosh Toolbox interfaces
        o 2.5) How can I compare two date strings?
        o 2.6) How do I get MacPerl to recognize the Mac character set?
        o 2.7) How do I access Mac Resources from MacPerl?
   * 3) MacPerl Application
        o 3.1) How do I package my Perl scripts?
             + 3.1.1) Droplets:
             + 3.1.2) Standalone applications/Runtimes:
             + 3.1.3) Which form should I use?
             + 3.1.4) What about other files to go with the package?
        o 3.2) Devices (printer, screen, appleevent):
             + 3.2.1) How can I get MacPERL to dial my modem?
             + 3.2.2) How can I keep local data files in my droplet/runtime?
             + 3.2.3) How can I output to another window?
             + 3.2.4) How can I get/set AppleEvent data?
        o 3.3) How do I develop scripts?
             + 3.3.1) Alpha Text Editor:
             + 3.3.2) BBEdit Text Editor:
   * 4) MacPerl MPW tool
        o 4.1) Installation of MPW MacPerl
             + 4.1.1) Use the following steps:
        o 4.2) Specific differences between the MPW tool and Perl under Unix
   * 5) Special Application Areas
        o 5.1) How can I extend the capabilities of MacPerl?
             + 5.1.1) Perl Modules
             + 5.1.2) Perl Extension System (XS) and dynamic loading of
               extensions.
        o 5.2) How do I program for the Web?
             + 5.2.1) How do I serve Web information (CGI)?
             + 5.2.2) How do I mail the contents of a filled in form?
             + 5.2.3) How do I create or parse HTML documents?
        o 5.3) Portability tricks and techniques
             + 5.3.1) How do I know that this script is running under
               MacPerl?
             + 5.3.2) How do I get input from the user of the script?
             + 5.3.3) How do I pass parameters to the script?
        o 5.4) How do I know what directory the current script is in?
   * 6) Misfeatures and Bugs
        o 6.1) Misfeatures
             + 6.1.1) Why does the here-is document not get read properly?
             + 6.1.2) Why does MacPerl not work with Netscape?
             + 6.1.3) When I try to read a particular file, why does MacPerl
               complain that it is "out of memory"?
        o 6.2) Bugs
             + 6.2.1) I can't get my droplet to run when I drop files on it?

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

1) General Questions

1.1) What's the most recent version of MacPerl?

MacPerl is available in forms corresponding to Unix Perl version 4.036 and
5.001m. Both of these are also available as either a standalone Macintosh
application, or as a tool for the MPW (Macintosh Programmer's Workshop)
environment.

Unless you already have MPW, and know its environment, you want the
standalone version, hereafter called the MacPerl Application.

Perl5 introduced several powerful new technologies, including
object-oriented programming to the PERL project. This allowed modules to be
much more self-sufficient, yet extensible, as well as allowing system
extensions. These extensions will be capitalized upon in further releases of
MacPerl.

1.1.1) Perl 5

The latest version of Perl 5 is available from the CPAN archives in
directory http://perl.com/CPAN/ports/mac/ as files:

Mac_Perl_tool.bin
     for the MacPerl tool
Mac_Perl_appl.bin
     for the MacPerl application
Mac_Perl_tool.bin
     for the MacPerl tool from Switzerland
Mac_Perl_tool.bin
     for the MacPerl application from Switzerland

Both of these files are in MacBinary format. Other versions may also be
available in those directories. For MacPerl 5, the version naming convention
also refers to the Unix Perl version. For example, MacPerl version 5.0.1r1m
can be deciphered as follows: 5 is the major Perl release, .01 is the Mac
revision level, and 1m is the patchlevel of the Perl core.

The source code for these versions is also available in the same directory.
Consult the file Mac_Perl.info for details on which sources are needed for
which version.

1.1.2) Perl 4

The last version of Perl 4 ported to the Mac is MacPerl 4.1.8, which
corresponds to Unix Perl version 4.036 (the last release of Perl 4). While
it is quite stable, and has a lot of users still, MacPerl4 is no longer
being developed. Many of the newer Perl modules will not work with Perl 4.
The latest versions (4.1.8) are available from the CPAN archives in
directory ports/mac/ as file:

http://perl.com/CPAN/ports/mac/Mac_Perl_tool
     for the MacPerl tool
http://perl.com/CPAN/ports/mac/Mac_Perl_appl
     for the MacPerl application
ftp://ftp.switch.ch/software/mac/perl/Mac_Perl_tool
     for the MacPerl tool from Switzerland
ftp://ftp.switch.ch/software/mac/perl/Mac_Perl_appl
     for the MacPerl application from Switzerland

Both of these files are in MacBinary format.

1.2) How do I install MacPerl?

No matter which version of MacPerl you need, the installation process is
quite similar.

1.2.1) Transferring the files:

Be sure to transfer the files in binary mode.

After decompressing the archive, be sure to read all the text files in the
top level directory. (Or just review them if you're upgrading.)

1.2.2) How do I unpack the stuff I got?

In order to enable transmission of Macintosh files across the internet, they
must be encoded in various formats. Each layer of encoding adds a suffix to
the file. All MacPerl distribution files are StuffIt formatted archives,
encapsulated in MacBinary. Use StuffIt Expander, or a similar utility, to
decompress the files. See the comp.sys.mac.comm FAQ for a more complete list

1.3) What Macs does MacPerl run on?

MacPerl4 runs on any Macintosh, including the PowerMacs. MacPerl5 runs on
the same Macs mainly, with the exception of 68000-based machines. A 68000
savvy version of MacPerl5 will likely be available later in 1996.

1.4) Other MacPerl resources:

A primer on using MacPerl has been developed by Sandra Silcott. It's
available for FTP as a self-extracting archive. The porter of MacPerl,
Matthias Neeracher, maintains a question-and-answer list of his own. The
list is mailed periodically to macperl list subscribers, and is available at
his site.

1.4.1) Is there an email list for MacPerl?

Yes! To join, send mail to mac-perl-request@iis.ee.ethz.ch whose BODY (the
Subject is ignored) is the word "subscribe" or "unsubscribe". If you send
your subscription notice to mac-perl, you will merely annoy people.

1.4.2) What other useful resources are there?

     Newsgroups:
   * comp.lang.perl.announce
   * comp.lang.perl.misc
   * comp.lang.perl.modules

A searchable archive of the mailing list is available.

2) MacPerl Differences

2.1) What are the differences in functions on MacPerl?

Differences
 Routine          MacPerl4                         MacPerl5
 alarm        Not implemented
 chmod               Meaning of the mode of files is different
 chown                   Meaning of ownership is different
 chroot                           Not implemented

 crypt        Not implemented        Implemented but not distributed in the
                                                   sources.
 dump                      Not implemented. See runtimes.
 exec                             Not implemented
 exit     Needs to be accompanied by MacPerl::Quit to do what you expect.

 fcntl     Meaning of controls is   Meaning of controls is system specific.
              system specific        POSIX.pm provides a useful interface.
 fork                             Not implemented
 getlogin
 getpgrp
 setpgrp
 getppid
 getpw*                           Not implemented
 getgr*
 setgr*
 endgrent
 endpwent

 ioctl     Meaning of controls is   Meaning of controls is system specific.
              system specific        POSIX.pm provides a useful interface.
 kill                             Not implemented
 link                             Not implemented
 msg*                             Not implemented
 open         Pipes are not supported, except with ToolServer support.
 pipe             Not implemented, except with ToolServer support.
 shm*                             Not implemented
 syscall                          Not implemented
 time                          Uses January 1, 1904.
 utime                          Not 100% compatible
 umask                                           Does nothing
 wait                             Not implemented
 waitpid                          Not implemented

2.2) Compatability with Unix Perl

2.2.1) Why does source preprocessing (-P) not work?

Language processors on Unix have traditionally allowed arbitrary front end
preprocessing for their input. The Mac has not.

Perl5 has significantly extended the syntax and the preparation so that most
preprocessing is not needed. The usual use of preprocessing is to provide
manifest constants. Subroutines can be made into "bare-words", which allow
what-look-to-be constant values, like ENOFILE, to be used in Perl code.

2.2.2) How do I open a pipe both to and from a command?

You don't on the Mac.

2.2.3) Why do %ENV changes not pass to processes that I start?

The environment variables are aspects of Unix and MSDOS command processing.
They are supported only within single processes on the Mac for compatibility
purposes.

2.2.4) Why don't backticks work as they do on Unix?

The Mac OS doesn't (really) support the notion of subprocesses. These can be
faked from MacPerl and MPW if you have an application called "Tool Server".
Tool Server is sold as part of various Mac development tools (such as
Symantec C and Metroworks). Even so, there are many limitations that are not
present under Unix.

Matthias has hardcoded some strings to be processed by MacPerl itself.

pwd  Current working directory.
Directory
     Current working directory.
hostname
     Hostname as returned by MacTCP or OpenTransport.
stty -raw
     Allow single character input from the keyboard.
stty -cooked
     Allow normal character input (line-oriented) from the keyboard.

See the documentation file MacPerl.Specifics in your release for up-to-date
information. (This file has been superceded in MacPerl5 by the
pod:macperl.html file).

For greater portability, there is a module called Cwd.pm which sets the
environment variable PWD. For instance,

    use Cwd;
    chdir_init;
    $p = $ENV{'PWD'};
    ...
    chdir $newdir;
    $p = $ENV{'PWD'};

2.3) MacOS file system issues

2.3.1) How do I request an input or output file under MacPerl?

require 'StandardFile.pl';

$infilename = &StandardFile::GetFile('TEXT','ttxt','ttro' , "Default file");
$outfilename = &StandardFile::PutFile("Output file", "Default output file");

2.3.2) Why can't I detect aliases in my script?

Droplets *never* see aliases in @ARGV, as the finder resolves them before
Perl sees them.

The same is true for the results of standard file calls.

This is about to be fixed in MacPerl5r2.

2.3.3) How do I pass environment variables to my script?

The "environment" parameter must be passed as a list of strings (name/value
pairs). Here is a snippet that works:

property env : {"HOME", "Boot", "TEMP", "Boot:Temporary Items"}