Hi,
I'm trying to control a loop so that the header is only printed once within the loop. Obviously, with my current code, the header will inherent the loop propertie; it will get printed
multiple times if there is more than one record.
Should I use labels and use the "next" function ?
Any help or guidance would be appreciated.
Thanks
Code:
open (FILE, "File.txt") or die("Error");
while ( my $records = <FILE>) {
chomp $records;
my @field=split(/\|/,$records);
$Value0 = $field[0];
$Value1 = $field[1];
# Print header once if at least one record exists
if ($Value1 ne '') {
print qq(
------------------------- \n
| VALUE ID | VALUE NAME | \n
);
}
# Print not Null records
if ($Value1 ne '') {
print qq(
| $Value0 | $Value1 | \n
);
}
}
close FILE;