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

Re: [MacPerl] Writing line-ending agnostic scripts?



At 3:58 Uhr +0200 01.08.1997, Paul J. Schinder wrote:
>Michael Schuerig <uzs90z@ibm.rhrz.uni-bonn.de> writes:
>}It's night of the living dead again...
>}
>}Apart from converting line-endings before stuffing files into MacPerl is
>}there a way of writing scripts in a way that they recognize all the common
>}line-endings as what they are intended?
>}
>
>Are you talking about the scripts or text files read by the scripts?  If
>you're talking about Perl scripts themselves, the answer is no.  MacPerl
>wants Mac text, Unix Perl wants Unix text (I just checked), etc.  Text data
>files of any format are trivial to deal with using $/.  If you don't know
>beforehand what kind of text a file is, you can always read in a chunk with
>read() or sysread(). count the numbers of \015's and \012's, and proceed
>accordingly.

Sorry for being ambiguous. I didn't have scripts in mind. Converting them
is no big deal. I thought of files read in by scripts. Some time ago I
wrote a script that converts flat javadoc generated HTML files into a
folder hierarchy and wondered why MacPerl choked on the larger files --
well, of course they use linefeeds at least the ones that I've seen so far.

Similar problems occur in lots of other cases where files from different
platforms are involved, especially when they're acquired in archives and no
implicit conversion is done.

I'd like best if MacPerl had an option to treat \015, \012 and \015\012 as
line endings. Thinking of it this might be very useful when Rhapsody
arrives as we probably have to get used to different line-endings in files
created on the same machine.

Michael



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