Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PERL PARSER - Having trouble parsing data from a text file

Status
Not open for further replies.

fumang

Technical User
May 14, 2002
7
US
I'm having trouble parsing a certain section from a text file. This section of the text file is below:

---S&E
O1 RRM/LCC U34/MSS *MSAAM
MSSGRP.WCOMMWI/LPIC MCI
/LPCX 0222/LPCA SN, 01-27-03
/PIC MCI/PICX 0222/PCA SN,
01-27-03
O1 AYW
O1 ESC
O1 ESL
O1 ESX
O1 CFZ/RCYC 4/CFND 1 866
862-3526
O1 GCZ/CFNB 1 866 862-3526
PG 01
D1DN0030U 02L (FP ZAA 01056 071503 0054 00488 071103 2042)
O1 N7PXA
O1 UYP
O1 U21
O1 U9SAT
O1 POR1X
O1 NPU

What I need to do is grab the first letter, the second number, the first 3-5 letters before the / and then identify 2 pieces of data between each / /. My output file would look like this, delimited by a |.
O|1|RRM|LCC|U34
O|1|RRM|MSS|*MSAAMMSSGRP.WCOMMWI

What I'm having trouble with is how the line breaks into the next page. Right now my perl parser reads each line <> and tries to identify all the variables. I can't seem to get my output to include all the data between the / / delimeters in my input file. If anyone has any ideas that would be greatly appreciated.

Thanks!
 
I bet the problem is the delimiter you are using for the match operator. The match operator can use any delimiter that you choose. In order to change the delimiter, you have to specify the match operator 'm'. You want to pick a delimiter that is not part of your data. Here's some examples:

$FirstWord =~ /(\w+)/; # Use / as delimiter (no m needed)
$FristWord =~ m|(\w+)|; # Use | as delimiter
$FirstWord =~ m~(\w+)~ # Use ~ as delimiter
 
I would say exactly the same thing - it would help if you posted your regexp / code for inspection.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top