flounder's explanation was really thorough, but just to build on it a bit, it looks like you want to first make sure that your string ends in a digit (good practice), then, as long it it does, do different things depending on which number it is. That would look something like this:
if ($path =~ m/(\d+)$/)
{ my $end_num = $1;
if ($end_num == 0)
{ etc.
}
and so on for other numbers
}
else
{ print "Oh dear, my path doesn't end with a number\n";
}
One other thing to note is that this'll check for one *digit* at the end of your string, so if your end number might go into double figures remember to stick a '+' sign into your regex:
m/(\d+)$/
Hope that helps
Dennis