One clever way to open the source file is open 0; you then read the source code with <0>. This works because, when you pass open a single argument, it serves as the filehandle and the name of the scalar variable holding the filename. So, open 0 opens filehandle 0 on the file named in $0.