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

Thanks for the quick replay. Yes, this is true but the question is why I didn't get any error? Thanks in advance

Replies are listed 'Best First'.
Re^3: subroutine no error
by AppleFritter (Vicar) on Jul 23, 2014 at 10:40 UTC

    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.

      Thanks for the explanation. Now all is clear. Adrian