Okay, use <> (see "I/O Operators" in the perlop manpage) to read successive lines of your table. For each line you read, use split (perlfunc)to split up the line into an array (perldata) and if (perlsyn) to check if it's the right one. If it is, you can use a hash slice (perldata again) to easily assign the row's values to a hash to be used.
use strict; use Data::Dumper; my $rowid = $ARGV[0] || 'roy'; my %data = (); my @fields = split(/\t/, <DATA>); chomp @fields; while(<DATA>) { chomp; my @row = split(/\t/); if ($row[0] eq $rowid) { @data{@fields} = @row; last; } } if ( keys %data ) { # found, display data print Dumper \%data; } else { # not found, show error print STDERR "Can't find row '$rowid'\n"; } __DATA__ rowid course1 course2 course3 course4 marge psychology math engineering pe roy math reading art cooking
So now you'll need to replace reading from DATA with reading from an open filehandle, use CGI to get the $rowid passed from the form and put whatever HTML you want in the found/not found sections.
Good luck.
In reply to Re: Re: Re (tilly) 3: hash/array
by eg
in thread hash/array
by malaga
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |