Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Parse file with perl
02-13-2010, 04:07 AM
Post: #1
Parse file with perl
I am new to Perl and am trying to parse a message file and extract the data from the file that meet the criteria.
So what I am looking for are certain types of messages that are logged in a file.
Example: I only want to pull out the data(values) when it find the following strings:
id=
lo=
to=

Second part: How can pull out the data above that falls between each open and close <dsk1 ......... />


<dsk1 ldx="0" id="Apple_123" lo="90664930" to="50290243" rb="5601167285" wb="3166360469" re="207363559" we="141193363" rq="207492604" wq="152730850"
ure="207363559058" uwe="141193363182" urq="207492604103" uwq="152730850622"
pre="889919" pwe="878073" pro="889921" pwo="1100425" />
<dsk1 ldx="1" id="sun123" lo="91608370" to="51126057" rb="5666375308" wb="3212140435" re="209308380" we="135528403" rq="209434385" wq="147030757"
ure="209308380833" uwe="135528403621" urq="209434385336" uwq="147030757593"
pre="5767981" pwe="969224" pro="5768188" pwo="969226" />
<dsk1 ldx="2" id="Aix_123" lo="90127097" to="5016960222" rb="5586512947" wb="3160855300" re="206837302" we="140872186" rq="206955221" wq="153771898"
ure="206837302912" uwe="140872186968" urq="206955221962" uwq="153771898811"
pre="970954" pwe="902171" pro="970957" pwo="6395546" />


Would like parse the data and dislay in the following format. Display the results and seperate the output by a ;

id;lo;to
Apple_123;90664930;50290243
sun123;91608370;51126057
Aix_123;90127097;5016960222


Any help would be really appreciated
Find all posts by this user
Quote this message in a reply
Post Reply 


Forum Jump:

Contact UsDeveloper SolutionReturn to TopReturn to ContentLite (Archive) ModeRSS Syndication