Re: MacPerl Script on OS X

2008-02-29 Thread Dominic Dunlop

On 2008–02–28, at 22:52, Jay Savage wrote:

On Thu, Feb 28, 2008 at 4:03 PM, Ben Crane [EMAIL PROTECTED]  
wrote:

I have a Perl 4.X script that runs using MacPerl in Classic on my G5
Mac but I can't get it to run using Perl in 10.4.11.

What do I need to do to make it run?

Thanks for any suggestions.



Upgrade it work with Perl 5.x ;)


That's the way to go. Seriously. See below.



Seriously, though: what errors are you seeing? Does it rely on any
modules?


There weren't modules in Perl 4. People wanting such things did things  
in their own mutually-incompatible ways with do(file), eval and such.  
(The way I did it with eval in one big application stopped working in  
Perl 5, which interpreted it as method invocation ...)



Perhaps more importantly: is it set to be executable on 10.x?
Remember that the permissions scheme is different on X, and if it was
set to run under MacPerl on Classic, it won't be executable by
default.

Unfortunately, a *lot* has changed in the last 15 years (the last
perl4 release was in 1993), so I don't think anyone is going to be
able to give you a list of all the things that could be going wrong
off the tops of their heads.



There are about three pages on incompatibilities between Perl 4 and  
Perl 5 in Programming Perl (pages 590-593 in my 3rd edition).


For the hell of it, I just tried building perl-4.036 under Mac OS  
10.5.2, as that might be one way round your problem. I didn't get far  
(about as far as makedepend). There are antiquarians who like doing  
this sort of thing (see http://dev.perl.org/perl1/), but I don't  
number myself among them ...

--
Dominic Dunlop




Re: MacPerl Script on OS X

2008-02-29 Thread Jay Savage
On Thu, Feb 28, 2008 at 7:13 PM, Ben Crane [EMAIL PROTECTED] wrote:


 Jay,


 Thanks for your response copied below. I really don't want to go to Perl 5.x
 and all that newfangled stuff.


 Here's my code ending with the offending line 7 according to my BBEdit error
 msg also copied below. I think the problem must be something simple. BBEdit
 says the syntax is OK, and it does run OK under Classic. I've tried
 different path name conventions, ( / instead of : ) but that doesn't seem to
 help. All files have 777 permissions.


 1 #!/usr/bin/perl
  2
  3 # This script converts the file names of scans and images formed from the
 scans from consignor IDs
  4 # to lot IDs. The file g5hd:newScansImages:trans is formed by exporting
 from the filemakerPro records that
  5 # describe the lots and contain the images
  6
  7 open (trans, g5hd:newScansImages:trans) or die Error, can't open;
  8


Hi Ben,

First, you rinstinct to convert to OS X/unix-style filenames was correct.

Second, you'll want to add $! to your die messages. That will tell
you *why* the operation failed:

open (trans, g5hd:newScansImages:trans) or die Error, can't open: $!;

In this case, it's probably because the file doesn't exist, or your
script doesn't have read permissions for it, but you won't know for
sure until you see what $! returns on your system.

If the file does exist, make sure the user your script runs as can
read the file.

If the file doesn't exist, make sure you are opening the file in
read/write mode see perldoc open for more information, but something
like

open(TRANS, , path); # or
open(TRANS, , path);

should do what you need, depending on whether you need to read or write.

Also, keep in mind that filehandles should be barewords or variables,
not double-quoted strings. That can bite you later. By convention,
they're also usually uppercase. That makes it easier to tell the
difference between filehandles and other things.

HTH,

-- jay
--
This email and attachment(s): [  ] blogable; [ x ] ask first; [  ]
private and confidential

daggerquill [at] gmail [dot] com
http://www.tuaw.com  http://www.downloadsquad.com  http://www.engatiki.org

values of β will give rise to dom!