I have a simple script that opens a directory, reads through all the file names and then prints the output to a text file in a different directory. It looks something like this.
My Question is how to write to the file using $OutputDir for my path instead of including the entire path in the manner that I'm using now.
Any suggestions on how to do this or how to improve the script are greatly appreciated.
Thanks
My Question is how to write to the file using $OutputDir for my path instead of including the entire path in the manner that I'm using now.
Any suggestions on how to do this or how to improve the script are greatly appreciated.
Thanks
Code:
#!/usr/bin/perl use strict; use warnings; my $InputDir = '/home/files'; my $OutputDir = '/home/output'; opendir (DIR, $InputDir) or die "Couldn't open: $!; my $listing = `ls -l $InputDir`; open (MYFILE, '>/home/output/Output.txt') or die "Couldn't open: $!"; print MYFILE "$listing\n"; close (MYFILE); closedir(DIR);
Comment