AFAIK Perl will change \n to \n\r if used on Windows...
Dynamically changing $/ and $\ isnt recommended, unless you know what you're doing... 
in which case you should be localizing em.

> Have you tried setting the $/ (input record seperator) and $\ (output
> seporator) variable for all of your scripts to the same thing accross
> platforms. I don't know if the perl script also creats the data but if it
> does you can use the "\oXXX" control code to set this accross platforms.
> David Monarres <[EMAIL PROTECTED]>
> On Sun, 13 May 2001 18:15:41 David Falck wrote:
> > 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?

you can try a length $/ to determine the EOL indicator...

-- 
Greetz

Hendrik

... Quidquid perl dictum sit, altum viditur.

Reply via email to