Crombie Tools
splitcut.pl
Go to the documentation of this file.
1
#! /usr/bin/env perl
2
3
use v5.10;
4
5
my $cut = shift @ARGV || die "Usage: $0 cut";
6
7
my $balanced = qr/
8
(?(DEFINE)
9
(?<BAL_PAT>\(
10
(?:
11
(?> [^()]+ )
12
|
13
[^()]*(?&BAL_PAT)[^()]*
14
)
15
\))
16
)
17
/x;
18
19
# If starting and ending with () with balanced parentheses inside
20
# strip the beginning and end
21
if ($cut =~ /^(?&BAL_PAT)$balanced$/x)
22
{
23
$cut =~ s/^\(|\)$//g;
24
}
25
26
s/\s//g, say for (split /
27
\s* && \s*
28
(?![^(]*\))
29
/x, $cut);
scripts
splitcut.pl
Generated on Tue Nov 3 2020 04:04:03 for Crombie Tools by
1.8.12