On Mon, 28 Mar 2005 11:13:05 -0500, KEVIN ZEMBOWER wrote:
> I'm trying to read in text lines from a file that look like this:
[...snip...]

As others have said, you really should use a module. For completness,
here's a solution using Text::CSV::Simple ("datafile" holds the data
you gave in the question):

use Text::CSV::Simple;
my $parser = Text::CSV::Simple->new;
my @data = $parser->read_file("datafile");
for my $aref (@data) {
   my ($partno, $language, $title, $cost, $available) = @$aref;
   print "PN=$partno, L=$language, T=$title, C=$cost, A=$available\n";
}

Note that @data is an array of array references. I assign in the "for"
loop each one to a scalar called "$aref", and then de-reference it
using the "@$aref" notation.

Hope this helps,
-- 
Offer Kaye

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to