It looks like there is a single space between each data value; if
so, you can split on whitespace rather than all the nasty pattern
matching; did this not work for you?



On Thu, 7 Jun 2001, Brent Buckalew wrote:

> Hello all,
>
> I tried putting the following into the program but it doesn't read out the
> necessary data just yet.  I'm not sure why not.  I've had to modify it to
> the following so that it'll run and not complain to me.  Here's what it
> looks like now.
>
> do {
> $discard_line = <OUTFILE>;
> } until ($discard_line =~
> /\s+(Hydrogen)\s+(-\d+\.\d+)\s+(-\d+\.\d+)\s+(Log10 Me
> an Ionisation \(over radius\))/);
>
> and then follow with the
>
> while(<OUTFILE>){
> if
> (/\s+(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;}
>
> #lots of other comparisons here....
> }
>
> Anyone have any suggestions on another way of doing this?  Or am I fixing
> this one up the wrong way?  Thanks for any help.
>
> Brent
>
> > > > 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 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
> > > > >
> > > > >
> > > >
> > > >
> > >
> >
> >
>

Reply via email to