Search notes:

Perl module Tree::Parser

Tree::Parser can be used to parse text with a »tree structure« and create a Tree::Simple object from it.
#!/usr/bin/perl
use warnings;
use strict;
use feature 'say';

use Tree::Parser;
my $text = join "", <DATA>;

my $tree_parser = Tree::Parser->new($text);

# Each level has an indentation of two spaces:
my $space_indent = 2;
$tree_parser->useSpaceIndentedFilters($space_indent);

my $tree = $tree_parser->parse();
say ref($tree);
# Tree::Simple

$tree->traverse(sub {
  my $node = shift;
  say ('. ' x $node->getDepth() . $node->getNodeValue()); 
});



__DATA__
AAA
  A1
    a11
    a12
      a_1_2_1
  A2
    a21
BBB
  B1
  B2
  B3
    b31
    b32
      b_3_2_1
      b_3_2_2
    b33
CCC
DDD
  D1
    d01
EEE
  E1
  E2
    e21
    e22
      e_2_2_1
      e_2_2_2
      e_2_2_3
    e23
  E3
  E4
Github repository PerlModules, path: /Tree/Parser/script.pl

See also

Perl modules

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/developm...', 1745984493, '3.133.127.132', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/development/languages/Perl/modules/Tree/Parser/index(97): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78