Hi.  This is my first post.  I'm trying to write a script that retrieves data 
from a text file.  The text files have several hundred instances of the string 
"EAMBER (non-constraint) = #" where the # is a number that can be negative and 
the last spacing after the equals sign is variable.  My problem is in the 
loop; my expression matches ok, but it skips every other instance of the 
expression (leaving me with half my data).  I added the counting variable as a 
debug to see what was going on, and in files with 600 instances of the string, 
it ends up at 300.  Thanks a lot.

---------------------
#!/usr/bin/perl

print "Input file name: \n";
chomp($in_file = <STDIN>);

open (INFILE, "$in_file") or die ("Cannot open file");
open (EAMBEROUT, ">sum.EAMBER") or die("Cannot open file");

$EAMBER_count = 0;
while (<INFILE>) {
 if ($EAMBER = <INFILE> =~ /EAMBER\s\(non-constraint\)\s=\s+(.\d+.\d+)/c) {
  $EAMBERARRAY[$EAMBER_count] = $1;
  print EAMBEROUT "$EAMBER_count $EAMBERARRAY[$EAMBER_count]\n";
  $EAMBER_count++;
 }
}

close (INFILE);
close (EAMBEROUT);
--------------------

Neema Salimi
[EMAIL PROTECTED]

Reply via email to