Is it mandatory to save the perl file under cgi-bin location
No. It's configurable.
You can put them in any directory just make sure they are readable+executable by Apache.
<Directory /usr/local/apache2/htdocs/somedir> Options +ExecCGI </Directory>
The above directive tells Apache to permit the execution of CGI files. You will also need to tell the server what files are CGI files. The following AddHandler directive tells the server to treat all files with the cgi or pl extension as CGI programs:
AddHandler cgi-script .cgi .pl