onyourmark
asked on
print to file
Hi. Can someone tell me how to take this kind of code and have it be written to a new csv file called missingfiles.csv and with each line be a new line in the csv file?
Thank you.
Thank you.
for (my $t = $start_time; $t <= $end_time; $t += $step) {
my $file_name_pattern = strftime("%y-%m-%d_%H-*-*_sina.csv", localtime($t));
my @matched = glob($file_name_pattern);
print "File matching with $file_name_pattern is missing\n" unless @matched;
}
ASKER
Hi. Yes it is! By the way, I am not sure what happened with the points but I have applied for them to fix the situation.
For this, there were so many missing files that the command prompt cannot show them all. I just want to have the same output as the command prompt but in a text file.
For this, there were so many missing files that the command prompt cannot show them all. I just want to have the same output as the command prompt but in a text file.
Try this:
open(my $fh, ">", "files.csv")or die $!;
for (my $t = $start_time; $t <= $end_time; $t += $step) {
my $file_name_pattern = strftime("%y-%m-%d_%H-*-*_sina.csv", localtime($t));
my @matched = glob($file_name_pattern);
print $fh "File matching with $file_name_pattern is missing\n" unless @matched;
}
close $fh;
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you for all.
What do you want the CSV fields in each line be?