--- David Falck <[EMAIL PROTECTED]> wrote:
> 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) 

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

I'd say that depends on your restrictions.
Would your situation allow you to just always add the carriage return?
Unix systems usually just ignore it -- they don't choke -- and then it
would be there for DOSish OS's. If you always end records with \r\n
then they're always a known length again, DOS/Windows will be happy,
UNIX won't care, the seek() stays simple, the record write becomes
simple....

Would anything restrict you from just always adding it?

=====
print "Just another Perl Hacker\n"; # edited for readability =o)
=============================================================
Real friends are those whom, when you inconvenience them, are bothered less by it than 
you are. -- me. =o) 
=============================================================
"There are trivial truths and there are great Truths.
 The opposite of a trival truth is obviously false.
 The opposite of a great Truth is also true."  -- Neils Bohr

__________________________________________________
Do You Yahoo!?
Yahoo! Auctions - buy the things you want at great prices
http://auctions.yahoo.com/

Reply via email to