in reply to Perl string matching
It does look pretty messy.
The first line looks like it is meant to match a file path, but it doesn't seem to be entirely correct.
Each part in a pair of braces () in the regex will be held in one of the special variables $1, $2... etc.
I this case ^ means the regex will start looking from the beginning of the string. It will match any character (including null!) up to the first / in the string. I think the \ before the / is a red herring as it is escaping a character that does not need to be escaped here. / is a common regex delimiter and if / had been used in place of {} then the / would be correct.
It also tries to use three special variables ($1, $2, $3) with only two sets of braces to assign to them!
I would be tempted to rewrite the code using the File::Path module to separate the file and the path in this case.