in reply to Can't use undefined variable as a symbol reference

You declare $FH_OUT with my inside a while loop (lines 41 - 59). You then try to print to $FH_OUT outside the loop. Since you commented out strict (why?), you can do it, but $FH_OUT is undefined. Hence, the error.

Line 76 is the only place where $count is mentioned. That's what the warning tells you.

لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ
  • Comment on Re: Can't use undefined variable as a symbol reference

Replies are listed 'Best First'.
Re^2: Can't use undefined variable as a symbol reference
by wrkrbeee (Scribe) on Feb 08, 2015 at 22:41 UTC
    Thank you! Stupid of me to leave strict out of the code. Duhhh. Moved the output statement up inside the loop. Seems to work now. Any recommendations for improving the code? Thank you again for answering a stupid question.
Re^2: Can't use undefined variable as a symbol reference
by wrkrbeee (Scribe) on Feb 08, 2015 at 22:45 UTC
    Any recommendations for reading only the first 30 lines of a file?
      Use a counter. Once counter equals 30, exit loop.
        plus you can let perl do the counting. See perldoc perlvar, search for "$." or "input_line_number".