Re: [MacPerl-WebCGI] well split!!!

[email protected] Wed, 7 Mar 2001 10:08:23 -0500
Newsgroups perl.macperl.webcgi
Message-ID <p05010401b6cbf93bf22c@[64.194.142.225]>
-Bruce:

You said:

>Tedd -- Lose the "for (split(/\t/))" part :-)

And, then offered:

>open(DATA,$datafile) || &open_error($datafile);
>   while (<DATA>) {
>     next if /^$/;
>     my ($database_id, $category, $variable_name, $price, 
>$description, $item_number) = split(/\t/);
>
>     print "<TR>";
>     print "<TD>$variable_name</TD>";
>     print "<TD>\$$price</TD>";
>     print "<TD>$description</TD>";
>     print "</TR>";
>}

Your suggestion still just grabs the FIRST record from the data file, 
displays it and exits -- like:

	NAME         PRICE    DESCRIPTION

I want it to grab EVERY record in the data file and display them -- like:

	NAME         PRICE    DESCRIPTION
	Apple ][   $123.00    Computer
	...            $...            ...
	...            $...            ...
	...            $...            ...
	...            $...            ...

For whatever reason, my "for (split(/\t/))" allowed/made that to 
happen (i.e., listed ALL the data). It was my method of placing the 
variables into the table where I went wrong, and the reason for my 
post.

It appears to me (perhaps in my novice view of things) that when the --

my ($database_id, $category, $variable_name, $price, $description, 
$item_number) = split(/\t/);

-- statement is executed, that the entire data file is placed within 
the $_ variable (I can confirm this by printing $_). So, that appears 
to me to be the reason the while () loop is done only once. Hence 
only the first filling of the variables occurs. But, I want to grab 
all the data, a record at a time, and display them. Am I making any 
sense?

tedd
-- 
http://sperling.com/