in reply to Re: Cutting of Path
in thread Cutting of Path

If you want to match a literal string in a regex, then you really need to use \Q and \E: $files[$i] =~ m#^\Q$conf{rootdir}\E/(.*)$#;

That code can still fail on quite a few platforms (including the one used by the author of the original question).

You would probably be better off to use File::Spec for this kind of stuff (though it requires Perl 5.6, unfortunately).

        - tye (but my friends call me "Tye")

Replies are listed 'Best First'.
Re: (tye)Re: Cutting of Path
by buckaduck (Chaplain) on Mar 21, 2001 at 04:10 UTC
    How about this low-tech solution? Since the rootdir is at the start of the string...
    substr($files[$i], 0, length($conf{rootdir})+1) = '';
    buckaduck

    UPDATE: I added 1 to the length to deal with the extra forward slash character...