in reply to Regular Expressions, IF, Issue

Your first regex does not match against $test_match, because $test_match does not end in a non-/ character (which your regex requires). If $1 and $2 are displaying anything, they are displaying the previous values held by them. (They do not get set to undef when a regex fails, as is documented.)

In addition to this, the regex's beginning is needlessly ungreedy. /(.*)\/([^\/]+)$/ works the same way as yours, but is much faster. And consider using a different delimiter for your regex; m{(.*)/([^/]+)$} is much easier on the eyes!

I second the notion that you probably want to use File::Basename.


Jeff japhy Pinyan, P.L., P.M., P.O.D, X.S.: Perl, regex, and perl hacker
How can we ever be the sold short or the cheated, we who for every service have long ago been overpaid? ~~ Meister Eckhart