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: Beginner:
Parse text file

 



shanti.dhanus
New User

Nov 14, 2012, 12:32 AM

Post #1 of 3 (1621 views)
Parse text file Can't Post

Hi,

I have to parse below text file

Chassis: ch_09USE127C72T
========================
NAME : ch_09USE127C72T
HARDWARE_UNIT_TYPE : 9730
SERIAL_NUMBER : 09USE127C72T
MONITORING_HOST : x9730-node1
OVERALL_HEALTH_STATUS : DEGRADED

Servers
=======
NAME BAY
----------- ---
x9730-node1 1
x9730-node2 2

BladeEnclosure
==============
TYPE : bladeEnclosure
NAME : OA-984BE16182A9
UUID : 09USE127C72T
SERIAL_NUMBER : USE127C72T
MODEL : -
FIRMWARE_VERSION : -
STATUS : DEGRADED
LOCATION : -
PROPERTIES : -
MESSAGE : -
DIAGNOSTIC_MESSAGE : -

And it should return 3 separate arrays as below..

Array1
--------------------------------------------
Chassis: ch_09USE127C72T
========================
NAME : ch_09USE127C72T
HARDWARE_UNIT_TYPE : 9730
SERIAL_NUMBER : 09USE127C72T
MONITORING_HOST : x9730-node1
OVERALL_HEALTH_STATUS : DEGRADED

Array2
--------------------------------------------
Servers
=======
NAME BAY
----------- ---
x9730-node1 1
x9730-node2 2


Array3
--------------------------------------------
BladeEnclosure
==============
TYPE : bladeEnclosure
NAME : OA-984BE16182A9
UUID : 09USE127C72T
SERIAL_NUMBER : USE127C72T
MODEL : -
FIRMWARE_VERSION : -
STATUS : DEGRADED
LOCATION : -
PROPERTIES : -
MESSAGE : -
DIAGNOSTIC_MESSAGE : -


Please help me on this! I am very very new to perl!


(This post was edited by shanti.dhanus on Nov 14, 2012, 12:33 AM)


rovf
Veteran

Nov 14, 2012, 1:55 AM

Post #2 of 3 (1613 views)
Re: [shanti.dhanus] Parse text file [In reply to] Can't Post


Quote
Please help me on this! I am very very new to perl!


Sure, but you need to be more specific. Where exactly are you stuck? Best is you post part of your code where you are in trouble.
Also it helps if you tell us which other programming language(s) you are already fluent in.

One general suggestion: As a Perl beginner, start evey program with the following lines:


Code
use strict; 
use warnings FATAL => qw(all);
use diagnostics;


Once you are experienced enought, you can taylor this section according to your needs...


Laurent_R
Veteran / Moderator

Nov 14, 2012, 3:17 AM

Post #3 of 3 (1611 views)
Re: [rovf] Parse text file [In reply to] Can't Post

Parsing a file is one thing, but we would need to know what you want to do with the data afterwards.

 
 


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

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