Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

Re^3: Hello im new to programming i need help

by jethro (Monsignor)
on Feb 10, 2013 at 02:11 UTC ( #1018011=note: print w/replies, xml ) Need Help??

in reply to Re^2: Hello im new to programming i need help
in thread Hello im new to programming i need help

Well, this means that for example the variable $xC1 didn't get set to any value when you use it in line 80. Now lets look at the lines where you want to set the variable. It is in a part that is executed only when two if-clauses are true.

The warnings indicate that all variables that depend on the outer if-clause "if ($one[0]=~m/^HETATM/)" have the same problem. So this if-clause probably is never true for at least the first two executions of the outermost loop i.e. for the first two files (and it seems from your test output that there is a third file where the if-clause is successfully run through). Because of that the variables are empty and you get the warnings.

So you have to change your script so that when the information you seek is not in the file the rest of the loop isn't executed anymore.

For example:

foreach $file (@one) { my $allfound=0; ... if ($one[2]eq "C4") { $allfound&=1; $xC4=$one[6]; $yC4=$one[7]; $zC4=$one[8]; } if ($one[2]eq "C1") { $allfound&=2; $xC1=$one[6]; $yC1=$one[7]; $zC1=$one[8]; } if ($one[2]eq "C13") { $allfound&=4; $xC13=$one[6]; $yC13=$one[7]; $zC13=$one[8]; } } } close FILETWO; next if ($allfound!=7);

I'm using the first three bits in the variable $allfound to tell me if all if-clauses where run through at least once for this file.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1018011]
[thao4]: thao4
[hippo]: Indeed you are.

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (7)
As of 2018-02-21 09:38 GMT
Find Nodes?
    Voting Booth?
    When it is dark outside I am happiest to see ...

    Results (276 votes). Check out past polls.