in reply to lexical scope in if/elsif tests

You will have to drop the my statement in the elsif.

From the docs in perlsub:

The my operator declares the listed variables to be lexically confined to the enclosing block, conditional (if/unless/elsif/else), loop (for/foreach/while/until/continue), subroutine, eval, or do/require/use'd file.

CountZero

A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

Replies are listed 'Best First'.
Re^2: lexical scope in if/elsif tests
by AR (Friar) on Apr 05, 2010 at 13:45 UTC
    I ended up using a second variable name for the elsif test. Thanks for pointing me to the right place in the documentation.