in reply to Re^2: subroutine no error
in thread subroutine no error

Good question, actually: and my apologies, I misread your post.

Looking at the script again, I think that the reason is as follows. When Perl compiles your script, the fact that ave is called before %CS101 doesn't matter: by the time the Perl compiler gets to the body of ave, %CS101% has been declared and thus can be accessed.

However, when Perl runs your script, ave is called before %CS101 gets assigned a value, so the hash is empty and you don't get any output.

Replies are listed 'Best First'.
Re^4: subroutine no error
by adriang (Sexton) on Jul 23, 2014 at 10:51 UTC

    Thanks for the explanation. Now all is clear. Adrian