Re: [MacPerl-WebCGI] well split!! (Solved)
[email protected] Thu, 8 Mar 2001 10:16:23 -0500
| Newsgroups | perl.macperl.webcgi |
|---|---|
| Message-ID | <p05010404b6cd4b5a36e3@[64.194.142.225]> |
- Bruce:
>When you "configure the data file to have a <ret> at the end of each
>record", how are you doing this?
With the current data file in question, I have used MS Word to set
the tabs and returns and saved it as a text file. I also checked it
again with BBEdit. In both cases the data file is simply text file
with a (013 DEC) return. I have uploaded that file to my server.
Granted, I have not used both the linefeed and return together as an
EOR, but I shall try that -- after I try what's suggested below.
>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>) {
>
> # ...
> }
> }
Bingo.
I just tried using your ( local $/ = "\r"; ) statement and everything
works without using my (for (split(/\r/))) statement.
Hey, regardless of what anyone says, you people are pretty smart.
One last question on this subject (I promise). While it is easier for
me, can I proceed safely in my using <tab> and <ret> (i.e., 013 DEC)
for my data files if I subscribe to your ( local $/ = "\r"; )
statement? Or, should I change the way I'm doing things to be more
"acceptable" in the perl cgi world? In other words, should I change
my <ret> to be both a carriage return and linefeed (i.e., 013 and 015
DEC)?
Many thanks Bruce.
tedd
--
http://sperling.com/