Hi,
I have a perl script that connect to a webserver and downloads a file and do some calculations with the file. Something like the following..
Code:
my $url = "http://localhost/test/file1.txt";
my $content = get $url;
while ($content =~ m/(\S+) (\S+) (\S+) (\S+) (\S+) (\S+)/g) {
# Each file has 6 columns, thats why i split it up
#do calculations
}
All this is fine, but i want to change this so that the script will auto run on all files in the specified folder. So something like a 'ls' of the directory and then a loop to get the output from ls (or whatever) and run the calculations on the file one by one.. something like
Code:
ls into variable $filename #not sure how to do this part
while ($filename) {
my $url = "http://localhost/test/$filename";
my $content = get $url;
while ($content =~ m/(\S+) (\S+) (\S+) (\S+) (\S+) (\S+)/g) {
#do calculations
}
}
Any suggestion how to get that first part right? i.e To list the files in the directory one by one into a variable of some sort and then get the files one by one?
Thanks for any help