use v6;
my $file_name = "Z2020_G_004_202202161115.html";
my @table_header = ();
my @table_data = ();
my @file_lines = slurp( $file_name ).split: / \n /;
for @file_lines {
last if / '
' /;
if / '' (.+?) ' | ' $ / {
@table_header.push: $0;
next;
}
if / '' $ / {
@table_data.push: [];
next;
}
if / '| ' (.*?) ' | ' $ / {
@table_data[*-1].push: $0;
}
}
print( "{@table_header.join: ';'}\n" );
for @table_data {
print( "{.join: ';'}\n" ) if .elems;
}