* Tim Musson <[EMAIL PROTECTED]> [2004-09-21T09:25:23]
> It looks something like this;
> Name,Location,Function,IPAddress
> uas123,123 street,Mail,10.11.12.13
> uas321,123 street,Mail,10.11.12.14

As is often the case, I suggest going to the CPAN and searching for CSV.
You'll find lots of relevent modules.

Of course, if you want to take care of this yourself, as an exercise,
consider something long the lines of the following:

        open my $csv_file, '<', "filename.csv"
                or die "couldn't open file!";
        my @columns = split(/,/, <$csv_file>);
        chomp $columns[-1];
        my @rows;
        while (<$csv_file>) {
                chomp;
                push @rows, {};
                @[EMAIL PROTECTED] = split /,/;
        }

So:
        Read the first line and break it up on commas to get column names.
        Chomp the newline from the last column name.
        Keep reading line, chomping their newlines.
        Add an empty hash to the end of the rows, then populate it, matching
        column names to field positions.

That code is off-the-cuff, but should work, I think. :)  If not, or if
you want more information, just holler.

-- 
rjbs

Attachment: pgpXoqWq0mKDt.pgp
Description: PGP signature

Reply via email to