The cgi-bin is a directory set aside to allow executable files to run within the web server.
So take for example the following script:
CODE
#!/usr/bin/perl
print 'Hello world!';
if placed in a directory that is not the 'cgi-bin', the following would be outputted:
CODE
#!/usr/bin/perl
print 'Hello world!';
So it just outputs the source of the file (in some setups you would just receive it as download which depends on defined mime types), this is not the intended output; However if this script was placed in the cgi-bin, the following would be outputted:
CODE
Hello world!
Which is exactly what the script was intended to do.
The first line is called a 'shebang' and declares the interpreter to be used to parse the following script. Interpreter paths differ on different setups, so it might be '/usr/local/bin/perl' or something similar, if you can execute shell commands, just issue 'whereis perl' or any other interpreter you wish to use and it will provide you with the path.