Well you could do it this way, if you're trying to read each line and process the same 
way
(Assuming you only want lines starting with Nitrogen, and the lines are all structured 
the same):
## START
while(<COMP2FILE>){

if (/^Nitrogen/) {
@List = split (/\s+/);
                if ($List[1] <= 0.0) {
                $name = $List[0];
                $nitrogenc1 = $List[1];
                $nitrogenc2 = $List[2];
                $nitrogenc3 = $List[3];
                $nitrogenc4 = $List[4];
                $nitrogenc5 = $List[5];

                #Do what you will
                }
}

}

# END

Or if you want to act on each line regardless of what it starts with:
#START:
while(<COMP2FILE>){

@List = split (/\s+/);
                if ($List[1] <= 0.0) {
                $name = $List[0];
                $nitrogenc1 = $List[1];
                $nitrogenc2 = $List[2];
                $nitrogenc3 = $List[3];
                $nitrogenc4 = $List[4];
                $nitrogenc5 = $List[5];

                #Do what you will
                }
}
# END

Hope that helps,

Greg


--- Brent Alan Buckalew <[EMAIL PROTECTED]> wrote:
> Hello all,
> 
> I've constructed a perl script to extract certain lines of data and print
> them out and use them in a later analysis.  The catch I've run into is
> that the style I used for the first batch doesn't work for
> the second.  I was wondering if any of you had a better/different way of
> getting the information.
> 
> Anyway, here's a portion of the input file.  I've added the <> to
> highlight the perl script or input files.
> 
> >
> Nitrogen 0.0  -5.78  0.0  0.0  0.0
> >
> 
> Here's where the above text is read in.
> 
> >
> while(<COMP2FILE>){
> 
>       if(/(Nitrogen) *([0-9.\-]*) *([0-9.\-]*) *([0-9.\-]*) *([0-9.\-]*)
> *([0-9.\-]*)/)
>       {
> if ($2 <= 0.0) {
> $name = $1; $nitrogenc1 = $2; $nitrogenc2 =$3; $nitrogenc3 = $4;
> $nitrogenc4 = $5; $nitrogenc5 = $6;}}
> }
> >
> 
> What it's doing with the data is that it'll read in the numbers up to the
> first negative number, then it just gives up and doesn't assign the -5.78
> to $nitrogenc2 in the example above.  I thought that adding the \- in
> the if conditional would correct the problem but it didn't.
> 
> If you have any suggestions for this problem, that'd be great.  Just two
> facts of improtance: (1) this is my first perl script and (2) I'm an
> astronomer and not a computer programmer.  The above is probably
> uaesthetically pleasing but it just has to run.
> 
> Thanks for your help!
> 
> Sincerely,
> Brent Buckalew
> 


__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail - only $35 
a year!  http://personal.mail.yahoo.com/

Reply via email to