# not fully tested, not properly adapted to the Tk case, # and likely has side effects BEGIN { # Search up the tree until we find the tk dir that contains a bin folder use Path::Class; use Config; use FindBin qw /$Bin/; #say "PAR_PROGNAME: $ENV{PAR_PROGNAME}"; my $prog_name = $ENV{PAR_PROGNAME} || $Bin; my @paths; use Config; my $tk_dir ='tk'; # add the tk bin dir to the path my $origin_dir = Path::Class::file($prog_name)->dir; ORIGIN_DIR: while ($origin_dir) { my $inner_path = Path::Class::dir($origin_dir, $origin_dir); #say "Checking $inner_path"; my $bin_path = Path::Class::dir($inner_path, 'bin'); if (-d $bin_path) { #say "Adding $bin_path to the path"; push @paths, $bin_path; } my $old_dir = $origin_dir; $origin_dir = $origin_dir->parent; last ORIGIN_DIR if $old_dir eq $origin_dir; } my $sep = $Config{path_sep}; $ENV{PATH} = join $sep, @paths, $ENV{PATH}; }