Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

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.


Comment on Re^3: Hello im new to programming i need help
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1018011]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (8)
As of 2014-12-19 23:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (94 votes), past polls