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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Advanced Pattern Searching Snippet

Status
Not open for further replies.

nanohurtz

Programmer
Mar 25, 2002
15
US
Hi,
I'm looking for a .pl code snippet that can read a .txt flat file of 12,000 jobs like the ones included below (FLATFILE INPUT) and output to 6 column .xls output as also included. Please note that some of the lines defy the $_=~/m^(.*)#(.*) or (SERVER)#(JOB) pattern because the flat file was generated from server SPBS565A. I need the first column of every instance of this occurance to be replaced with SPBS565A (See in red). Must be in .xls output because some SCRIPTNAME or DOCOMMANDS may have "|" delimiters in them..Any help is greatly appreciated.

FLATFILE INPUT (.txt)

MBQR123A#RPM123DP SCRIPTNAME "/usr/bin/tryout.sh"
STREAMLOGON "root"
DESCRIPTION "Experimental Script"
RECOVERY STOP
SDRF555A#RTD123DP DOCOMMAND "/usr/ben/hammerhead.sh"
STREAMLOGON "root"
DESCRIPTION "Some silly script"
RECOVERY STOP
GGG366DP SCRIPTNAME "/usr/local/sniffer.sh"
STREAMLOGON "fred"
DESCRIPTION "Checks for Ports"
RECOVERY STOP
UUU777RP DOCOMMAND "banner USA"
STREAMLOGON "samm"
DESCRIPTION "God bless America"
RECOVERY STOP
QWQW455A#CCX888DP SCRIPTNAME "/usr/bin/headache.sh"
STREAMLOGON "root"
DESCRIPTION "CPU Stablization"
RECOVERY STOP

SAMPLE FLATFILE OUTPUT (.xls)

MBQR123A | RPM123DP | /usr/bin/tryout.sh | root | Experimental Script | STOP
SDRF555A | RTD123DP | /usr/ben/hammerhead.sh | root | Some silly script | STOP
SPBS565A | GGG366DP | /usr/local/sniffer.sh | fred | Checks for Ports | STOP
SPBS565A | UUU777RP | banner USA | samm | God Bless America | STOP
QWQW455A | CCX888DP | /usr/bin/headache.sh | root | CPU Stablization | STOP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top