Problem in subroutine calling

Hi,
we can call the subroutines using two ways ....
1) calling subroutine name preceeded by & symbol.
2)Another one is without &symbol....
what is the diff b/w these two....
############################
#usr/bin/perl
fun;
sub fun
{
print "hi this is from perl\n";
}
############################
the above code is doesn't worked for me...... if i called like fun;
but i changed the subroutine call like this &fun;
then it works .............plz tell me what is happenning here.
In my project script, they called the subroutines either way....in that it works..........i tried this small experiment it doesn't worked.....plz help me out.
Thanks in advace...
Sarwan.

Very simply put, if you have the subroutine definition before the actual invocation, then you can call the subroutine as is i.e. without the ampersand. The subroutine acts like a builtin, in this case.

In case its the other way round, i.e. invocation comes first, and then the definition, you would need the ampersand to let perl know that you are refering to the subroutine defined later.

There are other instances where you cannot avoid the & way of invoking subroutines.

See the Oreilly sample chapter - Subroutines