Aaron Aaron - 1 month ago 14
Perl Question

Split unique forward slash

./dms:element[@name="obj_id"]/dms:qualifier[@name="object_status"]/@value[obj_id_status]


Trying to split the string so that the result comes out as

./dms:element[@name="obj_id"]
dms:qualifier[@name="object_status"]
value[obj_id_status]


Is there a way to do this with regex? I want to split when
/
is alone, but not split
./
and also remove
/@
.

Answer
my @parts = map s|^/\@||r, split qr|(?<!\.)(?=/)|, $s;

To remove slashes as well, whether or not they're followed by an @, it's

my @parts = split qr|(?<!\.)/\@?|, $s;