CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Advanced:
comparison deal with vector

 



AWHF
Novice

Jul 18, 2007, 8:53 PM

Post #1 of 2 (835 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:

Quote
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:

Quote
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?


Code
 #!/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";



KevinR
Veteran


Jul 19, 2007, 9:27 AM

Post #2 of 2 (827 views)
Re: [AWHF] comparison deal with vector [In reply to] Can't Post

By this time I would think you could do this type of programming yourself because you have been working on this same type of data extraction for a while now.

I suggest you continue on devshed where there are more active members availabe to anwser your questions.
-------------------------------------------------

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives