David,
My understanding is that you don't need to worry about what character(s)
contitute a newline. The different versions of Perl know about this and do
what you would expect.
So \n on UNIX is a LF and CRLF on DOS.
Did you already try this and encounter problems?
Mike
---
Mike Lacey
www.tek-tips.com -- a friendly, flame free, environment for computer
professionals and students
Perl forum at:
http://www.tek-tips.com/gthreadminder.cfm/lev2/4/lev3/32/pid/219
----- Original Message -----
From: "David Falck" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, May 14, 2001 2:15 AM
Subject: CR LF with UNIX and Windows (DOSish?)
> Is there a programmatic way to tell if I'm on Windows or UNIX? I know that
> $^0 returns the name of the operating system, but can I count on matching
> /MS/i or /Win/i to determine if it's Windows? If Windows, I'll assign 2 to
> $newline below, else I'll assign 1.
>
> Problem:
> I have a fixed length customer record. When I create the record, I add \n.
> But my testing tells me that when I read (seek) the record below, I have
to
> add 2 for Windows or 1 for UNIX.
>
> # Customer file data -
> $cst_template =
> "A9A15A15A1A30A30A30A30A9A2A13A40A13A5A2A16A2A2A1A1A10A10A10A7";
> $cst_rec_len = 303; # sum all customer fields
> $newline = 2; # changes based on OS
> $cst_offset = $cst_rec_len + $newline;
>
> # reading the customer record
> seek(CSTMST, ($rec_nbr * $cst_offset), 0) # $rec_nbr is the physical
record
> number
>
> Solution:
> Remove the hard coding above for $newline. Then assign 2 to $newline if
> Windows, else assign 1 to $newline. But do I look at $^0 to determine the
> operating system, or is there a better way?
>
> Thanks,
> David
>