473,387 Members | 1,441 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

comparison deal with vector

1
hey,

is there anyone who know how to deal with vector?
i have 2 files as below:
Expand|Select|Wrap|Line Numbers
  1. file1.doc
  2. ::component
  3. list
  4. ::Start 
  5. green[2:0] in grp1 
  6. blue in grp2
  7. orange[3:0] in grp3
  8. red[4:0] in grp5
  9. yellow in grp4
  10. ::End 
  11. Lab
  12. ::Engineering
  13.  
  14. ____________________________________________________
  15.  
  16. file1_fast.txt
  17. dont_touch : true ;
  18. area : 1 ;
  19. _power : 0.000 ;
  20. direction : inout ;
  21. capacitance : 123.456 ;
  22. /* automatically added to prevent m < errors */
  23. capacitance : 29.7 ;
  24. }
  25. name(green1) {
  26. direction : input ;
  27. capacitance : 14.370 ;
  28. }
  29. name(blue) {
  30. direction : input ;
  31. capacitance : 432;
  32. }
  33. name(green2) {
  34. direction : input ;
  35. capacitance : 14.370 ;
  36. }
  37. name(yellow) {
  38. direction : input ;
  39. capacitance : 432;
  40. }
  41. name(orange1) {
  42. direction : input ;
  43. capacitance : 15.5 ;
  44. }
  45. direction : input ;
  46. capacitance : 104 ; 
  47. name(orange2) {
  48. direction : input ;
  49. capacitance : 15.5 ;
  50. }
  51. direction : input ;
  52. capacitance : 104 ; 
  53. }
  54. name(red1) {
  55. direction : input ;
  56. capacitance : 14.370 ;
  57. }
  58. name(red2) {
  59. direction : input ;
  60. capacitance : 432;
  61. }
  62. name(red4) {
  63. direction : input ;
  64. capacitance : 15.5 ;
  65. }
  66. direction : input ;
  67. capacitance : 104 ;
  68. name(red6) {
  69. direction : input ;
  70. capacitance : 14.370 ;
  71. }
  72. name(orange5){
  73. direction : input ;
  74. capacitance : 432;
  75. }
  76. name(orange6) {
  77. direction : input ;
  78. capacitance : 15.5 ;
this mean my file have the following info:
Expand|Select|Wrap|Line Numbers
  1. file1.doc
  2. green1
  3. green2
  4. blue
  5. orange1
  6. orange2
  7. orange3
  8. red1
  9. red2
  10. red3
  11. red4
  12. yellow
  13.  
  14. file1_fast.txt
  15. green1
  16. green2
  17. blue
  18. orange1
  19. orange2
  20. orange5
  21. orange6
  22. yellow
  23. red1
  24. red2
  25. red4
  26. 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?
Expand|Select|Wrap|Line Numbers
  1. use Data::Dumper;
  2.  
  3. my $doc = '/home/assignment/file1.doc';
  4. my $txt = '/home/assignment/file1_fast.txt';
  5.  
  6.         open my $df, "<", $doc or die "can't open $doc: $!";
  7.         my @listDoc;
  8.         while (<$df>)
  9.         {
  10.                 if (/^::start/../^::start/)
  11.                 {
  12.                         next if /^::/;
  13.                         my ($infoDoc) = split / /;
  14.                         push @listDoc, $infoDoc;
  15.                 }
  16.         }
  17.  
  18.         my %hash;
  19.         open my $ff, "<", $txt or die "Can't open $txt: $!";
  20.         while (my $lineFast = <$ff>)
  21.         {
  22.                 if ($lineFast =~ /name\((\w+)\)/)
  23.                 {
  24.                         $hash{$1}='';
  25.                 }
  26.         }
  27.  
  28.         print Dumper \@listDoc, \%hash;
  29.         print "\n====================\n", join "\n", grep {!exists $hash{$_}} @listDoc;
  30.         print "\n\n";
Jul 19 '07 #1
0 1238

Sign in to post your reply or Sign up for a free account.

Similar topics

10
by: chandra.somesh | last post by:
Hi I recently had to write a small code in a competition ,but my code was rejected cause it failed in 1 of test cases. The problm was .....we are given vector of strings....each string...
2
by: PengYu.UT | last post by:
I'm wonder whether 1. stl directly defined the 6 comparison operators(== != < > <= >=) directly for iterator and const_iterator 2. or it only define == and < and using std::rel_ops to get the...
2
by: jcteague | last post by:
I have a class that has a set<int> member variable. the items in the set are selected indices of a vector. I would like to sort the set on the values in the vector they point too. Here is a part...
2
by: news.online.no | last post by:
Hi all Rather than writing std::binary:functions I thought it would be nice to create a comparison expression directly into the algorithm expression. Typical use is struct Person {...
4
by: Gary Wessle | last post by:
Hi I am writing a code to open a space delimited data file, return the number of rows and columns, as well as return the nth column where n is user define number. I put all the cells in a...
7
by: Alan | last post by:
Hi. I have programmed in C++ before, but I`m a couple of years out of practice. I am seeking some advice on getting started on a quickie project. . . . I have to read a 54MB text file and do a...
0
by: SvenMathijssen | last post by:
Hi, I've been wrestling with a problem for some time that ought to be fairly simple, but turns out to be very difficult for me to solve. Maybe someone here knows the answer. What I try to do is...
5
by: fade | last post by:
Good afternoon, I need some advice on the following: I've got a class that has a member std::vector<CStringm_vFileName and a member CString m_path; The vector contains a bunch of filenames with...
1
by: Alan | last post by:
I am wondering if anyone has any better idea of how to approach this problem than I do. . . . I have a vector of items (data). I have to do a pairwise comparison of each item to each other item...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.