mountainbiker
Programmer
Given a list like:
@x = qw(
/a1/a.html
/a1/b.html
/a1/g.html
/a1/x/d.html
/a1/x/e.html
/a1/x/r.html
/a2/d.html
/a2/c.html
/a2/r.html
/a2/x/h.html
/a2/x/f.html
/a2/x/w.html
/a3/d.html
/a3/c.html
/a3/r.html
/a5/r.html
/a5/x/h.html
...and so on...
);
Parsing the path/filename, the first occurrence of A1, A2, A3,... should be used to print a section header. Under that directory, when the first occurrence of a file is found in the x subdirectory, it should cause "SUB-SECTION" to be printed. In short, the output desired is something like:
SECTION A1
/a1/a.html
/a1/b.html
/a1/g.html
SUB-SECTION
/a1/x/d.html
/a1/x/e.html
/a1/x/r.html
SECTION A2
/a2/d.html
/a2/c.html
/a2/r.html
SUB-SECTION
/a2/x/h.html
/a2/x/f.html
/a2/x/w.html
SECTION A3
/a3/d.html
/a3/c.html
/a3/r.html
SECTION A5
/a2/r.html
SUB-SECTION
/a2/x/h.html
@x = qw(
/a1/a.html
/a1/b.html
/a1/g.html
/a1/x/d.html
/a1/x/e.html
/a1/x/r.html
/a2/d.html
/a2/c.html
/a2/r.html
/a2/x/h.html
/a2/x/f.html
/a2/x/w.html
/a3/d.html
/a3/c.html
/a3/r.html
/a5/r.html
/a5/x/h.html
...and so on...
);
Parsing the path/filename, the first occurrence of A1, A2, A3,... should be used to print a section header. Under that directory, when the first occurrence of a file is found in the x subdirectory, it should cause "SUB-SECTION" to be printed. In short, the output desired is something like:
SECTION A1
/a1/a.html
/a1/b.html
/a1/g.html
SUB-SECTION
/a1/x/d.html
/a1/x/e.html
/a1/x/r.html
SECTION A2
/a2/d.html
/a2/c.html
/a2/r.html
SUB-SECTION
/a2/x/h.html
/a2/x/f.html
/a2/x/w.html
SECTION A3
/a3/d.html
/a3/c.html
/a3/r.html
SECTION A5
/a2/r.html
SUB-SECTION
/a2/x/h.html