Hi,
I need some ideas because I'm just trying and error programming.
I have some .dat files that come in this format (call this file dat.dat):
# # Field1 description of Field1 # Field2 description of Field2 # Field3 description of Field3 # Field4 description of Field4 # Field5 description of Field5 # "Field1" "Field2" "Field3" "Field4" "Field5" "Field1" "Field2" "Field3" "Field4" "Field5" "Field1" "Field2" "Field3" "Field4" "Field5" "Field1" "Field2" "Field3" "Field4" "Field5" "Field1" "Field2" "Field3" "Field4" "Field5"
And I have another two files, one a csv file with this format (call this file csv.txt):
Description Field1a, Description Field2a Field1a, Field2 Field1a, Field2 Field1a, Field2 Field1a, Field2
And another one that just contains (call this file pc.txt);
Field2 Field2 Field2 Field2
What I need to do is search for each field that appears in pc.txt, if this field doen't exists in the dat.dat file, then I need to delete the row in csv.txt that contains Field2.
To search this I have this:
sub openReadFiles { sysopen(PCERROR, "$dir/$pointcodeError", O_RDONLY) or die "Cannot open file $pointcodeError for reading!\n"; @pcError = <PCERROR>; chomp(@pcError);
sub openWriteFiles { sysopen(PCCSV, "$dir/$ss7SigGroupPointcode", O_RDWR) or die "Cannot open file $ss7SigGroupPointcode for read/write!\n"; @pcCsv = <PCCSV>; chomp(@pcCsv); }
sub ParseData {
@out = @_;
for (@out) {
s/^\s+//g;
s/\s+$//g;
s/\s+/ /g;
# s/\d+,//g;
# s/\d+'//g;
}
return wantarray ? @out : $out[0];
}sub closeAll {
close(PCERROR);
close(SS7NODE);
}sysopen(SS7NODE, "$dir/$ss7Node", O_RDONLY)
or die "Cannor open file $ss7Node for reading!\n";
openReadFiles();
while (<SS7NODE>) {
(($nodeId, $name, $nodeSetId, $pointCodeId, $nodeType, $desc, $monitored) = split(' ')) if ($_ !~ /^#/); #This is to not consider the # at the begining of the .dat file
foreach $pcError (@pcError) {
print ("\t\t$name\n");
}
closeAll();But I don't know how to do it to test for the Field2 and delete this field from csv file
Hope somebody can help me. I think I just need some guides or examples to see how this kind of things could be achieved.
Thanks in advance
-- (o_ Pablo A. Wolter N. //\ Usuario Registrado #284649 V_/_ Linux Debian Sid Kernel 2.6.8
"Pienso....luego instalo Linux....entonces existo."
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>
