in reply to Re^4: Group __DATA__ lines in a while?
in thread Group __DATA__ lines in a while?
If you are interested in a more compact style, you could be writing your @sections loop as
section($tab, sub { for my $line (@$_) { heading($tab,$1,$2, { id => idify($2) }), next if $line =~ /^( +[1-6])\s+(.*)/; line($tab,$line), next if $line =~ /^< +/; line($tab,"<$line>"), next if $line =~ /^[ +bh]r$/; paragraph($tab,$line); } }) for @sections;
I like this for its tabular look where the action is on the left and the condition on the right. It also avoids the chain of elsifs. The danger is that it becomes difficult to stay the course when the actions become more complex...
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^6: Group __DATA__ lines in a while?
by Lady_Aleena (Priest) on Oct 24, 2013 at 04:48 UTC | |
|
Re^6: Group __DATA__ lines in a while?
by Lady_Aleena (Priest) on Nov 10, 2013 at 23:16 UTC | |
by hdb (Monsignor) on Nov 11, 2013 at 08:44 UTC | |
by Lady_Aleena (Priest) on Nov 11, 2013 at 10:14 UTC | |
by Anonymous Monk on Nov 11, 2013 at 10:33 UTC |