I'm out standing in my field, duh!

[email protected] (tedd) Mon, 5 Mar 2001 20:38:21 -0500
Newsgroups perl.macperl.webcgi
Message-ID <p05010400b6c9ea12b34e@[64.194.142.225]>
Hi:

I'm trying to open and read a data file on a server. The data file is 
a tab/carriage-return delimited file (consisting of fields separated 
by tabs and records separated by carriage-returns).

When I use the following code --

	open(DATA,$datafile) || &open_error($datafile);
	while (defined($_ = <DATA>))
		{
		for (split)
			{
			@line = split(/\t/, $_); 		#tab 
and returns

			$database_id = $line[0];
			$category = $line[1];
			$variable_name = $line[2];
			$price = $line[3];
			$description = $line[4];
			$item_number = $line[5];

			print "$database_id\n";
			print "<p></p>\n";
			print "$category\n";
			print "<p></p>\n";
			print "$variable_name\n";
			print "<p></p>\n";
			print "$price\n";
			print "<p></p>\n";
			print "$description\n";
			print "<p></p>\n";
			print "$item_number\n";
			print "<p></p>\n";
			}
		}

-- it prints the entire contents of the file. However, so does the 
following code:

	open(DATA,$datafile) || &open_error($datafile);
	while (defined($_ = <DATA>))
		{
		for (split)
			{
			@line = split(/\t/, $_); 		#tab 
and returns
			$database_id =   $line[0];
			}
		}

What gives?

I can't seem to dump the fields of the file into the variables I 
want. Everything gets dumped (assigned) into the first variable, 
namely $database_id. I want to be able to load the different 
variables with the different fields from my data file. Anyone have an 
easier way of doing this?

Many thanks for any replies.

tedd
-- 
http://sperling.com