Fwd: Re: [MacPerl-WebCGI] well split!! (Solved)

[email protected] Thu, 8 Mar 2001 12:53:08 +0900
Newsgroups perl.macperl.webcgi
Message-ID <v04011701b6ccae08a1bf@[211.19.94.253]>
Adam Witney <[email protected]> wrote:
>>It seems that your while(<DATA>) part is still reading the whole file in in
>>one go...

[email protected] wrote:
>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 the $_. After that, the "\t" further evaluates the
>$_ with respect to tabs?

Adam's right - the while{} loop works according to the value of $/, which
is usually '\n'  unless as Bruce pointed out, you change it to something
else or something is messing with the returns - probably they're not being
converted when you transfer the file onto the  Linux box (presumably you
made the DB source file on another OS). So to get round this problem, and
have a script that will work as expexted on anything running perl add this
"s/\015\012|\012|\015/\n/g;"

here:
while (<DATA>)
   		{
		s/\015\012|\012|\015/\n/g;
		next if /^$/;  # skip empty lines


and take out :

for (split(/\r/)) # find returns


Also the chomp() is optional seeing as how you're outputting HTML unless
you start using pattern matches or counting the number of characters in
each string.


HTH

Robin