I want to use Perl to split the path
funit/pipe/str/str32/gt/split
up to
funit/pipe/str/str32/gt
using a regular expression.
I want to use Perl to split the path
funit/pipe/str/str32/gt/split
up to
funit/pipe/str/str32/gt
using a regular expression.
It looks like you just want the path to the parent directory; is that right? I wouldn't call it "splitting" the path
Is the restriction on using a regex pattern a genuine one, or did you just think it would be the best method?
Here's a program that uses Path::Tiny
to do what you ask
use strict;
use warnings 'all';
use feature 'say';
use Path::Tiny;
my $path = Path::Tiny->new('funit/pipe/str/str32/gt/split');
say $path;
say $path->parent;
funit/pipe/str/str32/gt/split
funit/pipe/str/str32/gt