in reply to Re: splitting data
in thread splitting data

I took this problem as inspiration to write a little script to visualize matching parantheses. I probably got carried away and it is not helping on the original problem.

use strict; use warnings; my $tlp_p2 = "(((((((NOT(tlp_p0(0) XOR tlp_add_p0(0)) AND NOT(tlp_p0(1 +) XOR tlp_add_p0(1))) AND NOT(tlp_p0(2) XOR tlp_add_p0(2)))"; my $level = 0; my $tab = "| "; my %action = ( '(' => sub { print "\n", $tab x ++$level, shift }, ')' => sub { print "\n", $tab x $level--, shift }, 'default' => sub { print shift }, ); ( $action{$_} // $action{'default'} )->($_) for $tlp_p2 =~ /./g;

The last line reads each character of the string $tlp_p2 individually and calls the corresponding sub from hash %action.