How about something like this?
# Get rid of all the lines up till the Nitrogen ones start:
do {
$discard_line = <OUTFILE>;
} until ($line =~ /Log 10 Mean Ionisation/)
# Then, process lines until no more Nitrogens:
while (<OUTFILE>) #Current line becomes the variable $_
{
break unless (/Nitrogen/); #if no arguments, matches on $_
@values = split; #splits intelligently on whitespace, on $_
# Then process the current array . . .
}
This also saves you time on pattern matches . . .
Also, the array knows its own length if there will be a varying
number of parameters.
Okay, bye.
On Tue, 5 Jun 2001, Brent Buckalew wrote:
> Hello all,
>
> This is similar to the problem I had before but the table that I'm reading
> from is a little bit different. We'll use the nitrogen as an example
> again.
>
> IN the test table there are four entires for nitrogen. Here they are.
>
> Nitrogen 0.00e+00 1.31e-02 9.86e-01 5.96e-04 0.00e+00 0.00e+00
> Nitrogen 9.99e-01 1.48e-03 1.59e-12 0.00e+00 0.00e+00 0.00e+00
> Nitrogen -30.000 -1.884 -0.006 -3.225
> Nitrogen 3.723 4.007 4.007 4.007
>
> The text that I'd like is the row of all negative numbers. Now, the perl
> command that I'm using to get this is the following:
>
> while(<OUTFILE>){
>
> if
> (/(Nitrogen)\s+(-\d+\.\d+)\s+(-\d+\.\d+)\s+(-\d+\.\d+)\s+(-\d+\.\d+)\s+(-\d+\.\d
> +)/)
> {$name = $1; $nitrogen1 = $2; $nitrogen2 =$3; $nitrogen3 = $4; $nitrogen4
> = $5; $nitrogen5 = $6;}
>
> }
>
> However, I believe this is choking when it gets to the first line that has
> nitrogen in it. It doesn't know what to do with the e's. What happens is
> that the material that I want never gets assigned to the variables. I've
> tested this by placing in the following print command.
>
> print COMPFILE "HEY, $nitrogen1, $nitrogen2, $nitrogen3, $nitrogen4,
> $nitrogen5 \n";
>
> Now, there is a key word which exists before getting to the desired line
> of Nitrogen and that's the following:
>
> Log10 Mean Ionisation
>
> So, is there a way of using this text in a while statement or something
> like that to get what I need? Or can I change the while statement
> above to get just the nitrogen line with just negative numbers? Thanks
> for your help.
>
> Brent
>
>