in reply to Several stupid questions about subs
Which text book is this? Where are you doing your course? It clearly isn't very good. I once observed an online training course for biologists to learn some basic Perl in which some of my colleagues took part. The guy who did it said that he advises against all that "strict, warnings and 'my'" stuff because he gets annoyed by all those error messages. Then he got himself into big trouble with a typo in a variable name which of course would have been caught by all those "annoying messages"! Took him ages to find the problem....
In short (and as already mentioned here): use strict (and warnings) and keep your variables scoped with 'my'. A good subroutine should have a clear input and output and have as few hidden side-effects as possible. Then it is clear to anybody what it does and it is easy to maintain the code. To achieve that you explicitly pass it the input variables, then access them with local variables as shown above ( something like my ($var1,$var2) = @_;) and then return one or more values explicitly. Sometimes a sub doesn't have an obvious return value and in that case you often return "1" or "0" to indicate success or failure of whatever the sub did.
Using global variables and making some changes to them somewhere in the sub means that it is not clear at all what it does and the hole point of making the sub (put some code in a blackbox), is lost.