Re: [MacPerl-WebCGI] well split!! (Solved)
[email protected] (Adam Witney) Wed, 07 Mar 2001 18:59:11 -0500
| Newsgroups | perl.macperl.webcgi |
|---|---|
| Message-ID | <B6CC357F.82B3%[email protected]> |
Hi Tedd,
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).
From "MacPerl Power and Ease":
On Unix systems, the line-ending separator (record separator) is the line
feed (ASCII \012). On MacOS, it's the carriage return (\015). On MS-DOS and
Windows systems, its the sequence "carriage return/line feed" (\012\015)."
and....
"...\r (which produces a return without a newline under Unix Perl), produces
a line feed under MacPerl."
What platforms are you running this on?
adam
> $datafile = "Database/outlet.data";
> open DATA, "$datafile" or die "Can't open $datafile: $!";
> while (<DATA>)
> {
> next if /^$/; # skip empty lines
> chomp; # remove the "line ending"
> for (split(/\r/)) # find returns
> {
> # find tabs
> my ($database_id, $category, $variable_name,
> $price, $name, $description, $item_number) = split(/\t/);
>
> print <<ROW; # place variables into table
> <TR>
> <TD>$database_id</TD>
> <TD>$category</TD>
> <TD>$variable_name</TD>
> <TD>\$$price</TD>
> <TD>$name</TD>
> <TD>$description</TD>
> <TD>$item_number</TD>
> </TR>
> ROW
> }
> }
>
> close DATA;
>
> print " </table>";
>
> __END__
>
> #---- end of code ----
>
> tedd
> --
> http://sperling.com/