Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: How to Save a variable outside of a loop

by RonW (Parson)
on Jul 31, 2015 at 21:33 UTC ( [id://1137065]=note: print w/replies, xml ) Need Help??


in reply to How to Save a variable outside of a loop

By declaring your variables inside the loop, they are being redeclared each time the loop executes.

If you move your declarations before the loop, it should work:

#!/usr/bin/perl use warnings; use strict; my $hitlength; my $prevalence; my $prev_l; my $prev_p ; while(<>){

Replies are listed 'Best First'.
Re^2: How to Save a variable outside of a loop
by Calebros (Initiate) on Jul 31, 2015 at 22:12 UTC
    Thank you very much Ron, you saved me a lot of hair pulling!

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (7)
As of 2024-04-23 16:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found