Hi,
My first thread was not very clear so I decided to create another one.
My objective is that the following fields (stored in flat file) would be displayed by category. The category would be the state which is the field [3].
-> Flat File Structure:
-> Would be displayed like the following:
Here's the coding:
It's the output section that I'm not able to produce correctly. Right now I'm able to display all results, but not separated by state. I think using map or grep would maybe the solution.
THANK YOU VERY MUCH IN ADVANCE.
WOULD BE REALLY APPRECIATED.
My first thread was not very clear so I decided to create another one.
My objective is that the following fields (stored in flat file) would be displayed by category. The category would be the state which is the field [3].
-> Flat File Structure:
Code:
John|Lopes|Student|OH
Brian|Palmer|Student|CA
John|Peters|n/a|OH
John|Patterson|nothing|CA
-> Would be displayed like the following:
Code:
[b]State: [i]CA[/i][/b]
|-----------+-------------+-----------|
|Brian | Palmer | Student |
|John | Patterson | nothing |
|-----------+-------------+-----------|
[b]State: [i]OH[/i][/b]
|-----------+-------------+-----------|
|John | Lopes | Student |
|John | Peters | n/a |
|-----------+-------------+-----------|
Here's the coding:
Code:
if ($input{'st'}) {
# Record fields.
# Field 0 = First Name -> $fields[0]
# Field 1 = Second Name -> $fields[1]
# Field 2 = Status -> $fields[2]
# Field 3 = State -> $fields[3]
# Open DB file
open(FILE,"Database.txt");
my @database=<FILE>;
close(FILE);
# Build list
foreach my $record (@database) {
chop $record;
# Split fields
my @fields=split(/\|/,$record);
# Unless all states
unless ($input{'st'} eq "all") {
# Narrow list by state if provided.
next if ($input{'st'} != $fields[12]);
# Delete records not matching state
}
if ($input{'name'}) {
# Inputted name
if ($input{'name'} eq $fields[0]) {
push (@found_set,[@fields]) ;
++$found_records;
}
}
}
&output;
}
It's the output section that I'm not able to produce correctly. Right now I'm able to display all results, but not separated by state. I think using map or grep would maybe the solution.
THANK YOU VERY MUCH IN ADVANCE.
WOULD BE REALLY APPRECIATED.