in reply to Tree path analyzer regex problem (maybe other issues)?
use strict; use warnings; use Data::Dumper; my @last = (); while(<DATA>) { chomp; my @paths = split /\|/; my $different = 0; foreach my $i (0 .. $#last) { last if $i > $#paths; if ($different or $last[$i] ne $paths[$i]) { $different = 1; print join('|',@paths[0 .. $i]),"\n"; } } foreach my $i ($#last+1 .. $#paths) { print join('|',@paths[0 .. $i]),"\n"; } @last = @paths; } __DATA__ Valentine's Day Valentine's Day|Cards Valentine's Day|Flowers Valentine's|Candy Valentine's|Telegrams
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Tree path analyzer regex problem (maybe other issues)?
by bryank (Acolyte) on Jun 23, 2009 at 16:50 UTC | |
by kennethk (Abbot) on Jun 23, 2009 at 17:05 UTC |