Does Android work with JRE 7? I can't find any documentation on it..


Question: Why do I have to explicitly add perl before the script for getops to run properly?
Answer: When you invoke your code as perl script.pl -f file, you are explicitly running the perl executable and passing it a filename and options to parse.  But when you invoke it as script.pl -f file, you are asking your login shell to run the file, which it will parse as a shell script in the absence of any other information -- this is not what you want, as your file is not a bash script, but a perl script!

Normally such information (what program to use to parse the script) is given in what is called a shebang line. If you add this to the top of your script, it should run properly:

#!/usr/bin/perl


(or perhaps #!/bin/env perl, if you want the env program to find perl in your $PATH for you).