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

[email protected] Wed, 07 Mar 2001 10:26:14 EST
Newsgroups perl.macperl.webcgi
Message-ID <[email protected]>
Hi,


(I'm just a newbie myself, but) how about something like 

for (  ($database_id, $category, $variable_name, $price, 
>$description, $item_number) = split(/\t/)  )

so that you get each record and split it, and make the assignment, too?

Regards,

Melora Adams

In a message dated Wed, 7 Mar 2001 10:10:09 AM Eastern Standard Time, [email protected] writes:

<< -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/
 >>