sub add_path { my ($self,$path) = @_; my $canonical_path = get_canonical_path($path); my @subpaths = splitdir($canonical_path); for my $index (0..$#subpaths) { next if (@subpaths[$index] eq ""); # Ignore empty strings my $parent_path = abs_path(catdir(@subpaths[0..($index-1)])); my $current_path = catdir($parent_path,@subpaths[$index]); my $original_path_flag = ($index eq $#subpaths); next if ($graph->has_vertex($current_path)); if (-l $current_path) { my @resloved_links = resolve_symlink($current_path); my $target_path = $resloved_links[1]; $self->add_path($target_path); $graph->add_edge($parent_path,$current_path); $graph->add_edge($current_path,$target_path); $graph->set_vertex_attributes($current_path, { "type" => "link", "target" => $target_path, "original" => $original_path_flag }); } elsif (-f $current_path) { $graph->add_edge($parent_path,$current_path); $graph->set_vertex_attributes($current_path, { "type" => "file", "original" => $original_path_flag }); } elsif (-d $current_path) { $graph->add_edge($parent_path,$current_path); $graph->set_vertex_attributes($current_path, { "type" => "dir", "original" => $original_path_flag }); } } } #### sub run_rexes { my ($self,$rexes_aref) = @_; foreach my $vertex ($graph->unique_vertices) { next unless ($graph->get_vertex_attribute($vertex, 'original')); if (is_regex_matches($vertex,$rexes_aref)) { $graph->set_vertex_attribute($vertex, "marked", 1); } } } #### /a/b/c/file /p -> /a/b/c