in reply to pattern matching
$file =~ m!(?:/\w+)+!; should do the trick.
Hope this helps, -gjb-
Update: You might consider using File::Basename, included in the distribution.