File::Spec is likely to be a more portable and less fussy way of managing path manipulations:
use strict; use warnings; use File::Spec::Functions qw(splitdir catdir splitpath); my $path = "/a/b/c/d/e/f"; my @foo = splitdir ($path); my $subpath = catdir (@foo[1..3]); # Note that the "volume" is blank s +o skip that print "Sub path = $subpath\n";
Prints:
Sub path = a\b\c
In reply to Re: Extract portion of string based on string separator
by GrandFather
in thread Extract portion of string based on string separator
by linuxfan
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |