home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / lang / perl / 7528 < prev    next >
Encoding:
Internet Message Format  |  1992-12-21  |  1.4 KB

  1. Path: sparky!uunet!zaphod.mps.ohio-state.edu!cs.utexas.edu!sun-barr!male.EBay.Sun.COM!exodus.Eng.Sun.COM!cleo.Eng.Sun.COM!tesh
  2. From: tesh@cleo.Eng.Sun.COM (Teshager Tesfaye)
  3. Newsgroups: comp.lang.perl
  4. Subject: Help on string match!
  5. Date: 18 Dec 1992 21:07:40 GMT
  6. Organization: Sun Microsystems, Inc.  Mt. View, Ca.
  7. Lines: 45
  8. Distribution: na
  9. Message-ID: <lj4fcsINN1lu@exodus.Eng.Sun.COM>
  10. Reply-To: tesh@cleo.Eng.Sun.COM (Teshager Tesfaye)
  11. NNTP-Posting-Host: cleo
  12.  
  13.  
  14. I have two "Big" files that I read into arrays:
  15.     File A - contains the string to be matched
  16.     File B - is the file on which the match is performed on.
  17.  
  18. Task:  
  19.  
  20.     I want to match each string in A inside B and append string,
  21.     STRING, after the match. So my final file C, should be a copy
  22.     of B with inserted STRING's .
  23.  
  24. The following is the approach I took but did not work:
  25.  
  26.     foreach $a_name ( @A_array ) {
  27.         for(;;) {
  28.  
  29.             if( $_ =~ "^ +[JKD]FF" ) {
  30.                 local($macname,$fname_net,$other) = split(' ',$_,3);
  31.  
  32.   ------->    if ( $a_name eq $flop_name ) {
  33.  
  34.                     # do something
  35.  
  36.                     &add_str_routine( x );
  37.                     last; 
  38.                 }
  39.  
  40.                 else {
  41.                     next;
  42.                 }
  43.         }
  44.     }
  45.  
  46.  
  47. I am having with the string match on the line that I show. Although
  48. I know that $a_name and $flop_name are identical strings this string
  49. match "ALWAYS" fails. Am I doing something wrong? Is there a better 
  50. way to go about this problem.
  51.  
  52. Thanks in advance.
  53.  
  54. Tesh.
  55.  
  56.  
  57.  
  58.