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

Re: [MacPerl] reading PC files script ???



At 07:01 PM 9/16/97 +0200, you wrote:
>hi,
>
>me again...
>
>The pb is that we use scripts that are shared by perl-win32 and macperl,
>and macperl is angry when he see pc files....
>
>I cannot use the $/ in order to tell macperl to change his EOL char
>because we do require of a lots of files that are macperl-native and
>pc-native (a mixed).
>
>if somebody has an idea ???
>
>sorry for thoses questions, but it would be a great thing to succeed:
>all unified in perl no matter the OS!!!!
>



(If you are dealing with opening a mixed batch of data files)
---------------------------------------------------------------------

If you wan't the macperl script to open a mixed batch of files that are PC
native and MacOS native.. and determine what linefeeds to use automatically:

Well, I believe the MacOS uses CR where as Windoze uses CRLF or some
variant on that. Why not treat CR as the end-of-line character and if there
are LFs in the file, remove them s/LF//g;

Other options include geting info on the file's creator. If you run the
script from a Mac, all PC transferred files should have that "PC" icon and
most likely the same creator ID. Open a file, determine the creator ID, if
the creator was a PC machine, translate the files to Mac CRs instead of PC
EOL before using it.

(I don't know _how_ to get info on the file's type and creator, but I know
from this list that other people know how to do this.)

Also, you could do some task-simplifying things such as _not_ using a
.3char ending for Mac files, but using one for every PC file. That way, if
the filename ends in .xxx you know you are dealing with a PC file and can
switch out the end of line characters with some subroutine.


------------------------------------------------------------
(If you are just worried about running the script with either Win32 or
Macperl)
------------------------------------------------------------

Create the 'master' script in MacPerl. In Win32, open the MacPerl Script,
translate the EOF characters, then 'eval' the translated perl script. 

For example:
c/> perl win.pl macscript.pl

Would launch win.pl, which has $ARGV[0] of macscript.pl. It opens
macscript.pl, (knowing to use Mac EOL characters) and translates it to a
Win32 EOF file.. which is saves out as win.macscript.pl and executes this
generated script (`win.macperl.pl`;) or (if the script is small)
concatonates mascscript.pl into a string variable $eval and performs
"eval($eval);" to execute the copy.



I don't know, something in there might help you out.

Robert Sweeney



***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch