It's perfectly normal that it prints nothing from an inline execution. I don't know how you could "open FILEHANDLE $0" an inline code.
When you copy it to a file, you have to make sure that it is an EXACT copy. Adding or removing a single whitespace anywhere will change the SHA512 and thus result in printing random characters, like what you had.
Empty lines are really empty, there's one trailing newline at the end so that the downloaded version works too, and the end of each line is really the end of the line (no trailing spaces). Only the fifth line is indented with exactly 3 spaces.