G'day amma,
Welcome to the monastery.
I had a few issues with your example.
-
$var2 begins with a '(' (left parenthesis) but that leading character is not present in the original string at that position.
-
Should tlp_add_p0(0)) have an additional trailing ')' (right parenthesis) to match the others?
-
Using etc is a bit vague so I'm guessing here. A better way to show this sort of thing is with an ellipsis, e.g. "A, B, C, ..., Z".
-
Is the pattern 'NOT(tlp_p0(N) XOR tlp_add_p0(N))' common throughout or are there other formats?
If the repeated, internal pattern is the same throughout, you can do something like this:
$ perl -Mstrict -Mwarnings -E '
my $x = qq{tlp_p2 <= (((((((NOT(tlp_p0(0) XOR tlp_add_p0(0)) AND\n
+};
$x .= q{ NOT(tlp_p0(1) XOR tlp_add_p0(1))) AND };
$x .= q{NOT(tlp_p0(2) XOR tlp_add_p0(2))) etc};
say for $x =~ /(NOT\(tlp_p0\(\d+\) XOR tlp_add_p0\(\d+\))/gm;
'
NOT(tlp_p0(0) XOR tlp_add_p0(0)
NOT(tlp_p0(1) XOR tlp_add_p0(1)
NOT(tlp_p0(2) XOR tlp_add_p0(2)
If you want to use split, I'd chop off any leading and trailing dross then split something like this:
$ perl -Mstrict -Mwarnings -E '
my $x = qq{tlp_p2 <= (((((((NOT(tlp_p0(0) XOR tlp_add_p0(0)) AND\n
+};
$x .= q{ NOT(tlp_p0(1) XOR tlp_add_p0(1))) AND };
$x .= q{NOT(tlp_p0(2) XOR tlp_add_p0(2))) etc};
$x =~ s/\A\w+ <= \(+(.*?)\) etc\z/$1/ms;
say for split /\)\s*AND\s+/ => $x;
'
NOT(tlp_p0(0) XOR tlp_add_p0(0)
NOT(tlp_p0(1) XOR tlp_add_p0(1))
NOT(tlp_p0(2) XOR tlp_add_p0(2))
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.