in reply to Stripping parts of paths from directory names

I don't think the tr/// operator does what you think it does in this case. tr/// operates on characters rather than strings. Here's my approach to the problem if I understand it correctly:
use strict; use warnings; my $file_path='/home/sites/site18/users/rjoseph/web/images/image1.jpg' +; my $break_point = '/web'; my @foo = split($break_point, $file_path); my $path = $break_point . pop(@foo); print $path;
This prints: /web/images/image1.jpg

Replies are listed 'Best First'.
Re: Re: Stripping parts of paths from directory names
by Coyote (Deacon) on Jan 06, 2001 at 15:10 UTC
    Or in one line ... map {$path="/web$_"} split('/web','/home/sites/site18/users/rjoseph/web/images/image1.jpg');print $path Yields: /web/images/image1.jpg ---- Coyote (aka: Rich Anderson)