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

Re: [MacPerl] Recognizing Unix Line Breaks



Lasse Hiller¿e Petersen <lassehp@imv.aau.dk> writes:
}Matthias Ulrich Neeracher wrote:
}>Oh, I'll be prepared to make either of these changes if you force my cold,
}>dead
}>fingers to the keyboard of my Mac :-)
}
}Don't you have any gloves?
}
}>(Actually, I have no philosophical objections against Lasse's proposal
}but the
}>effort to implement it is prohibitive. Juergen's proposal is simple to
}>implement, but I'm totally opposed to it.)
}
}Actually, we have a \s, except it's called $/. Problem is, everybody else
}seems to use \n instead. :-) So what we need is some way to make \n mean

To most of "everyone else", \n means \015\012 (Microsoft is a monument to
human stupidity in more ways than one).  Remember that Unix is a minority
operating system even compared to MacOS.  None of the Unix workstation
manufactures ship the kind of numbers that even Apple does, and Linux isn't
*that* popular.  I sometimes wonder if there aren't more MacPerl's
installed than Unix Perl's (of course, most Unix Perl installations are
shared among many).

$/ doesn't do what you'd like \s to do.  $/ gets appended to *every* line
you print, even when you don't really want it.  There's no simple way to do
what you want right now.  Perhaps the closest is to simply define:

$s = "\012";

and then train yourself to type things like

print "this is a line$s";

if you can untrain your fingers from typing \n at the end of every line.

}what we need it to mean. (Not want it to mean, I'd rather everybody agreed
}to the same linebreak convention everywhere. Well, with Rhapsody this
}problem will probably be handled somehow.)

Given the legacy, my bet is that \n = \015 and the path separator is :.
The beauty of \n defined as it is in the ISO standard is that code is
portable, so my guess is that almost every Unix utility I want to put in
the Yellow box (if I can) will simply run even if \n is \015 there.  The
exception will be, as with Perl scripts, networking software written by
people who insist on writing \r\n instead of \015\012.

}
}I'm absolutely not in any position to dispute or doubt your saying the
}effort is prohibitive. But may I out of pure curiosity ask as to why it is
}so?
}
}As I said in my first reply on this, there is a suboptimal solution to this
}(use \012 to mean LF, \015 to mean CR, and $/ to mean platform-specific
}line break, changing it when necessary), which only requires a little extra
}effort of the programmer (and the extra time it takes to figure out when a
}module you didn't write yourself forces $/ to \n behind your back.) So
}there is no big need for implementation. The case where one has to
}manipulate a foreign-platform file in its native format on a different
}platform is probably rare for most people anyway.

Agreed, and Perl is unusual in that it gives you tools to deal with this.
Imagine having to do this in C.

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


---
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