perl script

Hello, Experts
I'm asking (if possible) a little code that makes some transformation on a given text.
I've some bibliographical records in this format:

000000369 FMT   L BK
000000369 LDR   L -----nls--22--------450-
000000369 100   L $$a20130829a--------km-y0itay50------ba
000000369 2001  L $$a<<L' >>Arte della grammatica$$fLorenzo Valla
000000369 210   L $$aMilano$$cArnoldo Mondadori Editore$$d1990
000000369 BAS   L $$a1
000000369 BAS   L $$a68
000000369 BAS   L $$aRECUPERO BONFIETTI
000000369 COP   L $$sMANMO$$fCB806$$cM/Valla/E1$$iGFC-7794$$j28/11/1992$$p18,08$$mBOOK$$z36$$tBATCH

000000371 FMT   L BK
000000371 LDR   L -----nls--22--------450-
000000371 100   L $$a20130829a--------km-y0itay50------ba
000000371 2001  L $$aManuscript liisting for the authors of classical and late antiquity$$fRobert E. Sinkewicz
000000371 210   L $$aToronto$$cPontifical Institute of Mediaeval Studies$$d1990
000000371 BAS   L $$a1
000000371 BAS   L $$a68
000000371 BAS   L $$aRECUPERO BONFIETTI
000000371 COP   L $$sMANMO$$fCB806$$cA Phil/Sin/1(III)$$iGFC-12073$$j28/10/2003$$p19$$mBOOK$$z36$$tBATCH

<etc..>

I'd like to isolate -with a script- two parts of it and separate them with a "|"

the 2 parts that I want to isolate are the following:

1) begins always with "2001  L $$a" and ends always with  a "$"
2) begins always with "BAS   L $$a" and end with a newline

continuing the previous example, from the 2 previous records I'd like to obtain something similar to:

<<L' >>Arte della grammatica|1|68|RECUPERO BONFIETTI
Manuscript liisting for the authors of classical and late antiquity|1|68|RECUPERO BONFIETTI
<etc..>

Thanks in advance for your precious help,
fabianope
fabiano petroneAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ozoCommented:
perl -ne '/2001\s+L \$\$a(.*?)\$/ && print "\n$1";/BAS\s+L \$\$a(.*?)$/ && print "|$1";' <<'<etc..>'
000000369 FMT   L BK
000000369 LDR   L -----nls--22--------450-
000000369 100   L $$a20130829a--------km-y0itay50------ba
000000369 2001  L $$a<<L' >>Arte della grammatica$$fLorenzo Valla
000000369 210   L $$aMilano$$cArnoldo Mondadori Editore$$d1990
000000369 BAS   L $$a1
000000369 BAS   L $$a68
000000369 BAS   L $$aRECUPERO BONFIETTI
000000369 COP   L $$sMANMO$$fCB806$$cM/Valla/E1$$iGFC-7794$$j28/11/1992$$p18,08$$mBOOK$$z36$$tBATCH

000000371 FMT   L BK
000000371 LDR   L -----nls--22--------450-
000000371 100   L $$a20130829a--------km-y0itay50------ba
000000371 2001  L $$aManuscript liisting for the authors of classical and late antiquity$$fRobert E. Sinkewicz
000000371 210   L $$aToronto$$cPontifical Institute of Mediaeval Studies$$d1990
000000371 BAS   L $$a1
000000371 BAS   L $$a68
000000371 BAS   L $$aRECUPERO BONFIETTI
000000371 COP   L $$sMANMO$$fCB806$$cA Phil/Sin/1(III)$$iGFC-12073$$j28/10/2003$$p19$$mBOOK$$z36$$tBATCH

<etc..>
0
fabiano petroneAuthor Commented:
Hello, ozo
thanks a lot for the reply.
is it possible to put this code inside a little script that I call from a console like 'script.pl <input.txt>output.txt'?

thanks again,

fabianope
0
ozoCommented:
while( <> ){
  /2001\s+L \$\$a(.*?)\$/ && print "\n$1";
  /BAS\s+L \$\$a(.*?)$/ && print "|$1";
}
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
fabiano petroneAuthor Commented:
Super-Thanks!! :=))
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Perl

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.