in reply to Outliner Algorithm Ideas?

I would suggest that you store the items in an arrayref of hashrefs containing arrayrefs containing hashrefs, like so:

# Represents # AA Sections are cool # AB They are extremely cool # ABAA That's right, really cool # ABAB Again, really cool my $sections = [ {content => 'Sections are cool' }, {content => 'They are extremely cool', subsecs => [ { content => "That's right, really cool" +}, { content => "Again, really cool" }, ] } ];
Then, you can print the sections out with something vaguely resembling this
recurse_section( $sections ); sub recurse_section { my ($sections, @vaportrail) = @_; push @vaportrail, 'AA'; foreach my $section (@$sections) { print @vaportrail, " ", $section->{'content'}, "\n"; recurse_section($section->{subsecs}, @vaportrail) if defined $section->{subsecs}; $vaportrail[ $#vaportrail ]++ } }
That way, your model (the section data) doesn't get entangled with the view (what the numbering scheme looks like). Then promoting a section is as easy as a little data manipulation:
# Add a supersection above "They are extremely cool" my $moving_section = $sections->[1]; $sections->[1] = { content => 'And moving sections is easy too!', subs +ecs => [ $moving_section ] }; recurse_section( $sections );

You can tie your hashtable to a subroutine that translates the ABAAAC business to a list of array indices. That I'll leave to you. :)