in reply to Stripping parts of paths from directory names

Well, you'd get something like what you want by doing this:
$file_path =~ s#^$path##;
instead of this:
eval "$file_path =~ tr/$path//";
(heck, you could even do this, if you were in a silly mood:
($file_path) = split /$path/, $file_path, 1;
but I don't know that I'd recommend it)

but you might want to look in CPAN for better solutions to your underlying problem--they're out there.

By the way, you'll note that I used # instead of / for my separator--I almost always do that, especially when I've got lots of slashes in my pattern, as it makes it easier to see what's going on.

Update: I fixed some typos and stuff I didn't like.

Replies are listed 'Best First'.
Re: Re: Stripping parts of paths from directory names
by repson (Chaplain) on Jan 06, 2001 at 13:56 UTC
    Yep theres another solution out there and its File::Spec, part of a fairly standard distribution.

    The line wanted is $file_path = File::Spec->abs2rel( $file_path, $path );