in reply to Changing data output

And here is Yet Another Way using grep

@files = qw(/mydirectory/directory/test/z2.htm /mydirectory/directory/other/testhere.htm /mydirectory/directory/test/dir/z6.htm ); my $root = '/mydirectory/directory/'; my @paths = grep s#$root##, @files; print "$_\n" for @paths;

Replies are listed 'Best First'.
Re: Re: Changing data output
by Anonymous Monk on Jun 19, 2003 at 20:09 UTC
    grep is not a good solution for this problem. grep modifies the list in-place, then makes a copy for @paths. You end up with two (hopefully)* identical arrays.

    *If the match fails, that element will not be returned by grep, so will not be in @paths!