CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Advanced:
Attention Perl Experts!!

 



nanohurtz
Novice

Mar 6, 2002, 9:59 PM

Post #1 of 3 (2655 views)
     Attention Perl Experts!!  

Here's A Challenge !

I'm looking for a PERL code snippet that can parse a text file containing entries like this..

BATCH RAMS125A#REDMERGE
AND123AT
RRD456WT
WWS789WT
PLL665QQ
END
BATCH RSWS555A#BLUMERGE
POP555BT
III777CT
END
BATCH RCCS919A#WHTMERGE
UDE888QT
RXX818WT
END
BATCH RDDS919A#PRPMERGE
UDE888QT
RUU818WT
KJJ112WE
RTT900VC
END


into this...

RAMS125A | REDMERGE | AND123AT
RAMS125A | REDMERGE | RRD456WT
RAMS125A | REDMERGE | WWS789WT
RAMS125A | REDMERGE | PLL665QQ
RSWS555A | BLUMERGE | POP555BT
RSWS555A | BLUMERGE | III777CT
RCCS919A | WHTMERGE | UDE888QT
RCCS919A | WHTMERGE | RXX818QT
RDDS919A | PRPMERGE | UDE888QT
RDDS919A | PRPMERGE | RUU818QT
RDDS919A | PRPMERGE | KJJ112QT
RDDS919A | PRPMERGE | RTT900QT


Im able to script and trap the first two classes in an if statement

if (m/^BATCH (.*)#(.*)$/) {
$o_lvar=$1;
$o_rvar=$2;
print OUTFILE "$o_lvar\t$o_rvar\n";
}


but can't seem to get the internal loop perfected to capture the remaining multiple instance s of this pattern ([A-Z][A-Z][A-Z][0-9][0-9][0-9][A-Z][A-Z]$/) to create the table above.. Any help is greatly appreciated

-Perl Pete
-NanoHurtz

"The danger from computers is not that they will eventually get as smart as men, but
we will meanwhile agree to meet them halfway."
-Bernard Avishai


mhx
Enthusiast

Mar 6, 2002, 11:42 PM

Post #2 of 3 (2653 views)
     Re: [nanohurtz] Attention Perl Experts!! [In reply to]  

Duplicate posts aren't good. They're annoying. Frown Please don't post the same question in different forums. Normally people don't look into only one forum (at least, I don't) and it's boring to see the same question more than once. Besides, it's redundant and chances are pretty good that your duplicates are deleted anyway (of course not before they have annoyed others Wink).

Have a look at the intermediate forum for an answer to your post.

-- mhx

At last with an effort he spoke, and wondered to hear his own words, as if some other will was using his small voice. "I will take the Ring," he said, "though I do not know the way."

-- Frodo



Jasmine
Administrator / Moderator

Mar 7, 2002, 12:19 AM

Post #3 of 3 (2648 views)
     Re: [nanohurtz] Attention Perl Experts!! [In reply to]  

This thread is locked. Post continued at [url=http://perlguru.com/gforum.cgi?post=14798]http://perlguru.com/gforum.cgi?post=14798

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives