in reply to Re: lexical scope in if/elsif tests
in thread lexical scope in if/elsif tests

Not so: the $key and $val lexical variables are scoped to the whole of the if ... elsif ... else ... block. You get an error if you use them outside of that block.

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^3: lexical scope in if/elsif tests
by Anonymous Monk on Apr 05, 2010 at 15:07 UTC

    Good to know; I'll have to shift my perspective a little bit to make it look right.