From where did you got this script?
I can tell you how to open and close filehandle like this:
@array = <FH>;
This is for reading. For writing change "<text.txt" to ">text.txt". For appending ">>text.txt".
Now chomp function you could use for STDIN input. You can add use foreach to list file content from array. after close(FH). If you plan to read from file it means. Its very simple.