LinguaFranca
Technical User
Hope my question isn't too stupid but I just cannot get it working.
I have a database output like this:
and I need to modify a slice of data within these lines:
I'll have to uniquely sort all filenames in $files[3] of the lines pointed out above. When done I need the original output but then with the revised sorted data in it.
How do I define this? Up to now it only outputs the slice with the manipulated data. And my $_ only contains the first line of my input data file.
Here's what I have so far:
Not sure whether I am clear enough. Hope one of you guys can help.
I have a database output like this:
Code:
# ---------------------------------------------
#
# Exported Dictionaries:
#
# C:\TRANSIT.WIN\DB\CODA\INTELL
#
# Date of Export: 10.01.2005
#
# Format of Export: (ansi)
#
# Concept Number;[];Hdr->Datasource e-Procurement/e-Billing/e-Invoice Matching;Hdr->Datasource CODA-Intelligence;Hdr->OLE;Hdr->Entered By;Hdr->Date of Entry;Hdr->Last Update By;Hdr->Date of Last Update;Hdr->Datasource Workflow;Hdr->Subject Area;Hdr->Datasource Financials;Hdr->Datasource e-Finance;Hdr->Datasource e-Assets;
# Concept Number;[Language];Term;Definition;Index;Abbr./Acronym;Alternatives;Synonyms;Introduced as of version;Remarks;Hotkey;Irregular Plural;Cross-Reference;Part of Speech;Gender;Context;Source;Status;Entered By;Date of Entry;Last Update By;Date of Last Update;User 1;Valid upto/incl.;Validated by;Additional Status;Former Term;
#
# ---------------------------------------------
1; []; ; companyparameters.res; ; ; ; CAL; 11.11.2004; ; CODA-Intelligence; ; ; ;
1; [ENG]; 'From' cannot be empty.; ; ; ; ; ; v10.1; ; ; ; ; ; ; ; ; confirmed; ; ; CAL; 11.11.2004; ; ; ; ; ;
2; []; ; cpkpi.res; ; ; ; CAL; 11.11.2004; ; CODA-Intelligence; ; ; ;
2; [ENG]; 'From' date or period is after 'To' date or period.; ; ; ; ; ; v10.1; ; ; ; ; ; ; ; ; confirmed; ; ; CAL; 11.11.2004; ; ; ; ; ;
3; []; ; companyparameters.res; ; ; ; CAL; 11.11.2004; ; CODA-Intelligence; ; ; ;
3; [ENG]; 'Group' cannot be empty.; ; ; ; ; ; v10.1; ; ; ; ; ; ; ; ; confirmed; ; ; CAL; 11.11.2004; ; ; ; ; ;
and I need to modify a slice of data within these lines:
Code:
1; []; ; companyparameters.res; ; ; ; CAL; 11.11.2004; ; CODA-Intelligence; ; ; ;
2; []; ; cpkpi.res; ; ; ; CAL; 11.11.2004; ; CODA-Intelligence; ; ; ;
3; []; ; companyparameters.res; ; ; ; CAL; 11.11.2004; ; CODA-Intelligence; ; ; ;
5; []; ; kpiwizard.res; ; ; ; CAL; 11.11.2004; ; CODA-Intelligence; ; ; ;
6; []; ; genericlists.res, genericlists.res; ; ; ; CAL; 11.11.2004; ; CODA-Intelligence; ; ; ;
7; []; ; dimensioncostcentre.res, dimensioncustomer.res, dimensionemployee.res, dimensiongeneral.res, dimensionnominal.res, dimensionproduct.res, dimensionproject.res, dimensionsubaccount.res, dimensionsupplier.res, eventviewer.res, dimensioncostcentre.res, dimensioncustomer.res, dimensionemployee.res, dimensiongeneral.res, dimensionnominal.res, dimensionproduct.res, dimensionproject.res, dimensionsubaccount.res, dimensionsupplier.res, eventviewer.res, dimensioncostcentre.res, dimensioncustomer.res, dimensionemployee.res, dimensiongeneral.res, dimensionnominal.res, dimensionproduct.res, dimensionproject.res, dimensionsubaccount.res, dimensionsupplier.res, eventviewer.res, dimensioncostcentre.res, dimensioncustomer.res, dimensionemployee.res, dimensiongeneral.res, dimensionnominal.res, dimensionproduct.res, dimensionproject.res, dimensionsubaccount.res, dimensionsupplier.res, eventviewer.res, dimensioncostcentre.res, dimensioncustomer.res, dimensionemployee.res, dimensiongeneral.res, dimensionnominal.res, dimensionprod; ; ; ; CAL; 11.11.2004; ; CODA-Intelligence; ; ; ;
I'll have to uniquely sort all filenames in $files[3] of the lines pointed out above. When done I need the original output but then with the revised sorted data in it.
How do I define this? Up to now it only outputs the slice with the manipulated data. And my $_ only contains the first line of my input data file.
Here's what I have so far:
Code:
#!usr/bin/perl
use warnings;
use locale;
use strict;
open TERMSTAR, "INTELL.ANS" or die;
open OUTPUT, ">intell.output.ans" or die;
while (<TERMSTAR>) {
chomp;
#grab all header lines from export file
my @headers=grep /^[0-9]+; \[\]/, <TERMSTAR>;
#grab 4th slice of a header line
foreach my $fields (@headers){
my @files = split(/\; /, $fields);
my @filelist = split (/, /, $files[3]);
#uniq sort on filenames of slice 4
my %seen=();
foreach (@filelist) {
$seen{$_}=1;
}
my @uniqfilenames = sort keys %seen;
print OUTPUT join (", ", @uniqfilenames), "\n";
}
}
close OUTPUT;
close TERMSTAR;
exit;
Not sure whether I am clear enough. Hope one of you guys can help.