in reply to Reading from a file
If you want to be able to access the contents of the file again after initially reading it, slurp it into an array. This is as simple as
open FILE, "sample.txt" or die $!; my @lines = <file1>;
Now you can use @lines in whatever way you want.
Hope this helps