First always use strictures (use strict; use warnings;). That will tell you that \a, \d, \# and \h are not what you expect. It would also tell you that you are redefining $key which is probably not what you meant.
You seem to be confusing the roles of $key and $line.
Your regex matches a bunch of weird characters. It may be that you mean to match the complement of the set, in which case the set should start [^.
You would likely get much better answers if you told us what the problem is that you are trying to solve and showed us a little more of the code. It looks like you are trying to manipulate paths - you've already been told several times about modules that will help you with that.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
| A reply falls below the community's threshold of quality. You may see it by logging in. |