Hi,
I have a flat file with the following structure:
Note:
Field 0 is User ID
Field 5 is Parent USER ID they report to (if applicable)
Now I want to list this data so it would be like this
(Child under Parent which they report to)
- Peter Givens (211)
- Lopez Lucas (234)
- Rob Lumen (224)
- Roger Brodie (210)
- Jake Namol (221)
- Matt Lamon (223)
- Lithia Lumberg (227)
Code I have right now
Thank you in advance
I have a flat file with the following structure:
Code:
DataTest.txt
210|Roger|Brodie|RB|NY|
221|Jake|Namol|JK|NY|210
223|Matt|Lamon|MM|NY|221
227|Litia|Lumberg|LM|NY|221
211|Peter|Givens|BV|NY|
224|Rob|Lumen|RB|NY|211
234|Lopez|Lucas|LL|NY|211
Note:
Field 0 is User ID
Field 5 is Parent USER ID they report to (if applicable)
Now I want to list this data so it would be like this
(Child under Parent which they report to)
- Peter Givens (211)
- Lopez Lucas (234)
- Rob Lumen (224)
- Roger Brodie (210)
- Jake Namol (221)
- Matt Lamon (223)
- Lithia Lumberg (227)
Code I have right now
Code:
open(FILE,"$DataTest.txt");
my @database=<FILE>;
close(FILE);
foreach my $record (@database) {
chop $record;
# Split fields
my @fields=split(/\|/,$record);
push (@groups,[@fields]);
}
my $parent_group = "";
foreach my $group (sort {
if ($a->[0] eq $b->[0]) { $a->[0] cmp $b->[0] }
else { $a->[1] cmp $b->[1] } } @groups) {
if ($group->[5] ne $parent_group) {
print "$group->[1] <b>($group->[0])</b><br>\n";
$parent_group = $group->[5];
}
print " group->[1] <br>\n";
}
Thank you in advance