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

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



D.Thomas@vthrc.uq.edu.au (Danny Thomas) writes:
}
}Is there any reason MacPerl can't accept any reasonable definition of
}line-ends, or at least throw up a warning if it finds only one line: "this
}4,213 byte file was one line, perhaps it needs to be saved with Mac
}line-separators?".

But it *does* accept a reasonable definition of line-ends, the only one
that makes any sense: accept the ones on the platform you're on, but no
others.  That's what the base Perl code must do, that's what MacPerl does.

One can be spoiled by the fact that some other Mac programs don't care
among the three major line-end possibilities, especially the major text
editors.  If you were working on Unix, you'd make damn sure that your files
were Unix text before doing anything to them, because you'd notice the
screwiness right away after opening a script with, say, emacs.

The only reasonable solution is to make sure your Perl scripts are
converted.  Fortunately, this is easy.  The Perl script to do basic
end-of-line conversion is a one-liner.  I have conversion done
automatically for me whenver I (usually automatically) transfer scripts
among platforms.  Perl is a beautiful tool for doing this, because it has
-T and regexps (for those rare times when -T might lie) and can do both the
transfers and conversions internally.

(Does BBEdit tell you the type of text file you're working on?  Alpha
certainly does, and it's a very nice feature to have.)

}
}I suspect this is more a 'feature' of the Perl interpreter, rather than
}anything specific to MacPerl

And it's far easier to solve this "problem" by a few lines of Perl rather
than making major changes to the Perl interpreter itself.

}
}cheers,
}Danny Thomas

---
Paul J. Schinder
NASA Goddard Space Flight Center
Code 693, Greenbelt, MD 20771
schinder@pjstoaster.pg.md.us



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