
AWHF
Novice
Jul 18, 2007, 8:53 PM
Post #1 of 2
(517 views)
|
|
comparison deal with vector
|
Can't Post
|
|
hey, is there anyone who know how to deal with vector? i have 2 files as below: file1.doc ::component list ::Start green[2:0] in grp1 blue in grp2 orange[3:0] in grp3 red[4:0] in grp5 yellow in grp4 ::End Lab ::Engineering ____________________________________________________ file1_fast.txt dont_touch : true ; area : 1 ; _power : 0.000 ; direction : inout ; capacitance : 123.456 ; /* automatically added to prevent m < errors */ capacitance : 29.7 ; } name(green1) { direction : input ; capacitance : 14.370 ; } name(blue) { direction : input ; capacitance : 432; } name(green2) { direction : input ; capacitance : 14.370 ; } name(yellow) { direction : input ; capacitance : 432; } name(orange1) { direction : input ; capacitance : 15.5 ; } direction : input ; capacitance : 104 ; name(orange2) { direction : input ; capacitance : 15.5 ; } direction : input ; capacitance : 104 ; } name(red1) { direction : input ; capacitance : 14.370 ; } name(red2) { direction : input ; capacitance : 432; } name(red4) { direction : input ; capacitance : 15.5 ; } direction : input ; capacitance : 104 ; name(red6) { direction : input ; capacitance : 14.370 ; } name(orange5){ direction : input ; capacitance : 432; } name(orange6) { direction : input ; capacitance : 15.5 ; the info that need to extract is in orange color. this mean the following files will looks as follow: file1.doc green1 green2 blue orange1 orange2 orange3 red1 red2 red3 red4 yellow file1_fast.txt green1 green2 blue orange1 orange2 orange5 orange6 yellow red1 red2 red4 red6
This is the code to extract the info i wanted and do comparison but the problem is that i do not know how to deal with the vector. can anyone help me please? #!/usr/bin/perl use strict; use warnings; use Data::Dumper; my $doc = '/home/assignment/file1.doc'; my $txt = '/home/assignment/file1_fast.txt'; open my $df, "<", $doc or die "can't open $doc: $!"; my @listDoc; while (<$df>) { if (/^::start/../^::start/) { next if /^::/; my ($infoDoc) = split / /; push @listDoc, $infoDoc; } } my %hash; open my $ff, "<", $txt or die "Can't open $txt: $!"; while (my $lineFast = <$ff>) { if ($lineFast =~ /name\((\w+)\)/) { $hash{$1}=''; } } print Dumper \@listDoc, \%hash; print "\n====================\n", join "\n", grep {!exists $hash{$_}} @listDoc; print "\n\n";
|