Re: [MacPerl-WebCGI] well split!! (Solved)
[email protected] (Bruce Van Allen) Wed, 7 Mar 2001 17:55:07 -0800
| Newsgroups | perl.macperl.webcgi |
|---|---|
| Message-ID | <p05010406b6cc93de83ad@[205.179.215.44]> |
At 8:13 PM -0500 3/7/01, [email protected] wrote: >>I think you may have got it working by fixing the symptom rather than the >>problem. >> >>It seems that your while(<DATA>) part is still reading the whole file in in >>one go... this is most likely because you have the wrong line endings on the >>file for that OS. you are then "fixing" this by using the split(/\r/) part >>which splits the whole file content into lines at \r (this is what you >>wanted the while(<DATA>) to do in the first place). > >I'm not doubting you, but doesn't the first condition "\r" read the >data file and dump the first segment (i.e., start-of-first-record to >first-return) into [snip] > Apache/1.3.3 Cobalt (Unix) (Red Hat/Linux) PHP/3.0.7 > >Now, my data file is configured to have a <ret> at the end of each >record. I realize that a <ret> means different things to different >environments. All I know is that if I look at the ASCII values of >the data text file with a HEX editor, each record ends with 013 >(DEC) (00D (HEX)) (015 (OCT) which is a CR on the Mac. > >With that said, should I be using a different EOR delimiter? After >all, I can make it anything I want. > When you "configure the data file to have a <ret> at the end of each record", how are you doing this? By using "\r"? If so, that's the source of the whole problem you've been having with while (<DATA>) Either a) use "\n", which in Perl is whatever is used for the OS's native end of record/end of line, which could be \r\n, \n, \r in the usual meaning of those guys. (See Adam Whitney's references.) or b) set $/ locally to "\r" before you get to "while (<DATA>)". { local $/ = "\r"; while (<DATA>) { # ... } } HTH 1; -- - Bruce __bruce_van_allen__santa_cruz_ca__