--- "A. Pagaltzis" <[EMAIL PROTECTED]> wrote:
> makes no effective difference. Iâd attack this directly by
> cleaning up $ENV{PATH}:
>
> use Config;
> use File::Spec::Functions;
> use File::stat;
> use Fcntl qw( :mode );
>
> $ENV{PATH} = do {
> my $sep = $Config{path_sep};
>
> join $sep, (
> map { /(.*)/ }
> grep { ! stat($_)->mode & S_IWOTH }
> grep { file_name_is_absolute( $_ ) }
> split( /\Q$sep/, $ENV{PATH}, -1 ),
> );
> };
Turns out this solves an issue I have at work. There were two issues I
uncovered.
1. The server I tested this on had one entry in the PATH which didn't
exist on the server, so I first check to see if stat($_) returns a true
value.
2. There was a precedence problem. The not (!) binds tighter than the
bitwise and (&), so parentheses were needed.
$ENV{PATH} = do {
my $sep = $Config{path_sep};
join $sep, (
map { /(.*)/ }
grep { stat($_) && !( stat($_)->mode & S_IWOTH ) }
grep { file_name_is_absolute($_) }
split( /\Q$sep/, $ENV{PATH} ),
);
};
Cheers,
Ovid
--
Buy the book -- http://www.oreilly.com/catalog/perlhks/
Perl and CGI -- http://users.easystreet.com/ovid/cgi_course/