Sadly it doesn't. I'm not sure if things are complicated by the fact that the text field can contain asteris that are not considered part of a comment e.g.
case1
aaa|bbb|ccc|ddd|eee|fff * hhh /*xyzxyz*/ abc
or
case2
aaa|bbb|ccc|ddd|eee|fff * hhh /*xyz
sss|ddd|ggg|hhh|jjj|xyz*/ abc
or
case3
aaa|bbb|ccc|ddd|eee|fff * hhh /*xyz
jjj|kkk|lll|ppp|ooo|blah blah blah
sss|ddd|ggg|hhh|jjj|xyz*/ abc
Sometimes the comment block is in the same record, at other times it spans 1 or more records. So in the example I would still need to check (fff * hhh and abc ) to see if they met my pattern match (becuase they're outside the comment block. Having had only limited Perl exposure this is really taxing me.
| [reply] [d/l] |
If you remove the spaces from the left hand side of the substitution, or add the /x modifier, it will deal with all of those also. Not sure why I omitted the /x.
However, depending where the end of the comment comes, it can sometimes leave an extra newline, so an additional chomp is called for:
while( <DATA> ) {
chomp;
if( m[/\*] ) {
$_ .= <DATA> until m[\*/];
s[ \s? / \* .+? \* / \s? ][]smgx;
chomp;
}
print join '-', split '\|';
}
Any other late breaking 'funnies' you need to deal with?
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
| [reply] [d/l] |