Just another Perl shrine | |
PerlMonks |
Re: Any way to simulate a Windows path handling for File::Spec without Windows?by davido (Cardinal) |
on Sep 08, 2019 at 20:38 UTC ( [id://11105843]=note: print w/replies, xml ) | Need Help?? |
This isn't the point to your post but I wanted to mention a possible bug I noticed:
This probably ought to be my ($new_string, $longest_string) = ('','');, because later you're using $longest_string as a pattern with the s/$longest_string// construct. But being undefined is the least of your worries:
...produces...
If you use a part of a path as a regular expression pattern that pattern has all the semantics of a regular expression pattern. You probably want to use quotemeta or \Q, to play it a little safer. Otherwise, you're exposing the regex engine to user input, which should be considered hostile. One could create a path that results in a pattern that either fails to parse, or that parses but has abysmal performance. Dave
In Section
Seekers of Perl Wisdom
|
|