I am trying to create a script that will read text files and then parse them regardless of whether the text file is online or offline.
The autonomous part is executed using
open(FILENAME, "anyfilename.txt")
analyze_file();
sub analyze_file {
while (<FILENAME>) {analyze analyze}
}
Now for the online part, does it matter to read a text file on a website and then “open” it?
I hope to achieve this:
if ($offline) {
open(FILENAME, "anyfilename.txt")
}
elsif ($online) {
}
analyze_file();
sub analyze_file {
while (<FILENAME>) {analyze analyze}
}
There is "get (" http://weblink.com/textfile.txt;) ", but it creates a string. I cannot do while () with this string.
Does anyone know how to do this?
source
share