Given the input file:
----------------
A
----------------
information for A
on these lines
----------------
B
----------------
Something about B
on these lines
etc
I want to produce:
A: information for A
A: on these lines
B: Something about B
B: on these lines
B: etc
My attempt to use Raku to do this looks like:
#!/usr/bin/env raku
my $head-info;
for lines() -> $line {
given $line {
# when /^ '-' **16 $/ { } # skip dashed lines
when /^ '-' **16 $/ ^fff^ /^ '-' ** 16 $ / {
$head-info = $line;
say "set head-info $head-info";
}
default { say $head-info, ": ", $line; }
}
}
I tried some variations of this but never seem to be able to execute the block that sets $head-info. Uncommenting the line does skip the dashed lines.
I don't necessarily need to use ff or fff but I thought it would be appropriate here.