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!

How to parse data from a record with fixed data up to a point and then variable length information. 1

Status
Not open for further replies.
Dec 12, 2007
19
US
This is a Perl how do I do this question.

10622 2014-04-18 04:14:18.924064 EDT 10622 DEBUG: QUERY: insert into "EDWP06".ETL_STG.RQ_DRVR_UPDT next_data...

here is my input data. It is fixed positions up to the "EDWP06".ETL_STG.RQ_DRVR_UPDT

how do I extract the EDWP06, ETL_STG and RQ_DRVR_UPDT into three different vatiables without the "'s or the .'s ?????

The EDWP06, ETL_STG and RQ_DRVR_UPDT values change per record and their length changes too but they always have the "'s around the first field and then that is followed by a period, the second field and then another period and the third field.

I need some syntax help here.

Thanks
 
I would use something like this:
Code:
[COLOR=#804040][b]use strict[/b][/color];
[COLOR=#804040][b]use warnings[/b][/color];

[COLOR=#804040][b]my[/b][/color] [COLOR=#008080]$input_data[/color] = [COLOR=#ff00ff]'[/color][COLOR=#ff00ff]"EDWP06".ETL_STG.RQ_DRVR_UPDT[/color][COLOR=#ff00ff]'[/color];
[COLOR=#804040][b]print[/b][/color] [COLOR=#ff00ff]"[/color][COLOR=#6a5acd]\$[/color][COLOR=#ff00ff]input_data = [/color][COLOR=#008080]$input_data[/color][COLOR=#6a5acd]\n[/color][COLOR=#ff00ff]"[/color];

[COLOR=#0000ff]# remove all \"[/color]
[COLOR=#008080]$input_data[/color] =~ [COLOR=#804040][b]s/[/b][/color][COLOR=#6a5acd]\"[/color][COLOR=#804040][b]//g[/b][/color];
[COLOR=#0000ff]#print "$input_data\n";[/color]

[COLOR=#0000ff]# split with \.[/color]
[COLOR=#804040][b]print[/b][/color] [COLOR=#ff00ff]"[/color][COLOR=#ff00ff]Values extracted:[/color][COLOR=#6a5acd]\n[/color][COLOR=#ff00ff]"[/color];
[COLOR=#804040][b]my[/b][/color] [COLOR=#008080]@input_data_list[/color] = [COLOR=#804040][b]split[/b][/color]([COLOR=#804040][b]/[/b][/color][COLOR=#6a5acd]\.[/color][COLOR=#804040][b]/[/b][/color], [COLOR=#008080]$input_data[/color]);
[COLOR=#804040][b]foreach[/b][/color] [COLOR=#804040][b]my[/b][/color] [COLOR=#008080]$item[/color] ([COLOR=#008080]@input_data_list[/color]){
  [COLOR=#804040][b]print[/b][/color] [COLOR=#ff00ff]"[/color][COLOR=#008080]$item[/color][COLOR=#6a5acd]\n[/color][COLOR=#ff00ff]"[/color];
}

Output:
Code:
$input_data = "EDWP06".ETL_STG.RQ_DRVR_UPDT
Values extracted:
EDWP06
ETL_STG
RQ_DRVR_UPDT
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top