You could instead use an array of arrays.
use strict; use warnings; use Data::Dumper; my $i = 0; my $line = <DATA>; chomp($line); my $colums = { # hash ref to hold colum numbers map { $_ => $i++ } # map each column to a hash an +d give it the index split(/\|/,$line) # split it on the pipe and sen +d it to map }; print Dumper($colums); my $rows; foreach my $line (<DATA>) { chomp $line; push @$rows, [split(/\|/, $line)]; } print "Record 1: first = " . $rows->[0][$colums->{first}]; __DATA__ title|first|last|room|phone|email Mrs|Linda|Caralo|201|148|she@borg.org Miss|Jean|Androno|317|167|j@alo.com Mr|Steve|Paterman|101|100|steve@net.net
That way you don't reproduce colum information. Prob a better way to do this but here was my whack at it.
In reply to Re: Is this a reasonable data structure?
by eric256
in thread Is this a reasonable data structure?
by Theo
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |