How extract strings (perl)

Sample data:

revision001 |  some text | some text
Comment: some comment
Brief: 1) brief
        2) brief
------------------------------------------
revision002 |  some text | some text
Brief: 1) brief
2) brief
FIX: some fix
------------------------------------------
revision003 |  some text | some text
Comment: some comment

Q: how extract "Brief" and "revision"?

need output:

revision001
    Brief: 1) brief
            2) brief
revision002
    Brief: 1) brief
    2) brief

I'm try:
<command> | perl -ne 'print if (/^Brief: /../(?:.: )|(?:\-+)/ or /^revision[0-9] /)'

Please post the (incorrect) output.

<some command> | egrep -v "^\-+$" |  while read LINE; do
    [[ ${LINE} =~ "^revision[0-9]+"  ]] && { L_BRIEF="1"; L_REF=${LINE%%|*}; }
    if [[ ${LINE} =~ "^Brief: " ]]; then
        echo -e "${L_REF}\n\t${LINE}"; L_BRIEF="0"
    elif [[ ! ${LINE} =~ "^.+: " ]]&&[ "x${L_BRIEF}" = "x0" ]; then
        echo -e "\t${LINE}"
    else
        L_BRIEF="1"
    fi
done

not perl ... but working

$
$ cat f1
revision001 |  some text | some text
Comment: some comment
Brief: 1) brief
        2) brief
------------------------------------------
revision002 |  some text | some text
Brief: 1) brief
2) brief
FIX: some fix
------------------------------------------
revision003 |  some text | some text
Comment: some comment
$
$ ##
$ cat f1 |
> perl -lne 'BEGIN{undef $/}
>            while(/(revision.*\).*?\n).*?/msg){($x = $1)=~s/(Comment|\-+).*?\n| \|.+//g;
>            print $x}'
revision001
Brief: 1) brief
        2) brief
revision002
Brief: 1) brief
2) brief
$
$

tyler_durden

Thanks

New trouble. As prev.

file data.dat:

N xxx xxx 353
 & xxx 99 012
 & xxxx                         99 000
09203809 290188309
9210830 0293801
B <some digits>
 & <some digits>
 & <some digits>
N yy yyyy 400
 & yyyy 01 000
 & xxxx                         00 000
9909 0000 9990
000 FAIL ....
000 FAIL ....

try:

perl -ne 'print if /N\s+.+?(?!\s+\&.+)/s' ./data.dat

result:

N xxx xxx 353
N yy yyyy 400

need:

N xxx xxx 353
 & xxx 99 012
 & xxxx                         99 000
N yy yyyy 400
 & yyyy 01 000
 & xxxx                         00 000

and

N xxx xxx 353 xxx 99 012 xxxx                         99 000
N yy yyyy 400 yyyy 01 000 xxxx                         00 000
local $/="---";
open FH,"<a.txt";
while(<FH>){
 print $1,"\n",$2 if /.*(revision[0-9]+).*(Brief:.*?)(FIX|---)/s;
}

This gives the output as you said for your new trouble.

$/=undef;
open(FH,a);
$string=<FH>;
 while($string =~ s/(N(\s+.+){3}\s+( &.*\n)+)//m)
{
print $1;
print split(/\n/,$1);
print "\n";
}

Thanks!

#!/usr/bin/perl

$/=undef;
open(FH,a);
$string=<FH>;
while($string =~ s/(N(\s+.+)\s+( &.*\n)+)//m)
{
    print split(/\n/,$1)."\n";
}