http://www.perlmonks.org?node_id=964389


in reply to Help with Regular Expressions

There is a great CPAN module for this sort of thing: File::Spec.

Specifically, it sounds like you want abs2rel:

use File::Spec; my $rel_path = File::Spec->abs2rel($CurrentPath, $BasePath);

Or were you trying to avoid using it for some reason or other?

Replies are listed 'Best First'.
Re^2: Help with Regular Expressions
by FFSparky (Acolyte) on Apr 10, 2012 at 19:22 UTC
    Riales,

    Thanks!

    I was not aware of that module / abs2rel works just fine and I will now be using it.

    However I was hoping for a regular expression solution as I don't believe mine is the best and want to broaden my understanding use of these.