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