in reply to Extract portion of string based on string separator

Here's a couple of generic functions which you can re-use for similar purposes later.
sub path_parts(@) { shift=~m((/[^/]*))g } sub limit_list($@) { $#_=-1+shift; @_ }
You can use them for your current problem like this:
my $orig_path = "/a/b/c/d/e/f"; my $trunc_path = join '', limit_list( 3, path_parts( $orig_path ) );
A word spoken in Mind will reach its own level, in the objective world, by its own weight