Sure. Your problems are that:
- You have a space inside your split pattern. The space is treated literally, and is a required part of the match, which you obviously don't want.
- You have a dot (.) inside your pattern. The dot has special meaning inside a pattern, which is to match any character. If you want to split on a literal dot, you need to escape it with a backslash.
- If you correct the two problems above, you will find that your pattern will fail on some directories or files that have dot's in their names before the extension, such as C:\mydir.old\foo.txt. To fix this, you should use a pattern match instead of split, and anchor your match to the end of the string.
After these fixes, your code should look something like:
my ($extension) = $pubload =~ /\.(\w+)$/;
update: as
chromatic pointed out, the /g modifier on my regex was unnecessary, so I nixed it.
MeowChow
s aamecha.s a..a\u$&owag.print