#!/usr/bin/perl -w use strict; my $file = 'c:/data.txt'; my @data; my $line_cnt = -1; # get data in a 2D array @data[$record][$field] # open DATA, $file or die "Oops, Perl says $!\n"; while () { chomp; next unless $_; my @fields = split /\|/, $_; push @data, \@fields; $line_cnt++; } close DATA; # access data in our 2D array, note offsets are from 0 not 1 print "Line 2 element 3 is ", $data[1][2], "\n\n"; # dump all the data as an (indented :-) HTML table print "\n"; for my $line ( 0 .. $line_cnt ) { print " \n"; my @fields = @{$data[$line]}; for my $field ( 0 .. $#fields ) { print " \n"; } print " \n"; } print "
$fields[$field]
\n"; __DATA__ 1|A|B|C 2|D|E|F 3|G|H|I