Generating a list of virtualmin public folders for backup

The following perl script creates this at /root/bash-advanced-scripts/backupqueue.lst

my $filename = '/root/bash-advanced-scripts/backupqueue.lst';
open(my $fh, '>', $filename) or die "Could not open file '$filename' $!";
my @files = </etc/webmin/virtual-server/domains/*>;
foreach my $file (@files) {
    open   (FILE, "$file");
    while(my $line= <FILE> ){
        if ($line =~ /(^public_html_path=)(.*)/) {
            print "$2\n";
            print $fh "$2\n";
    close FILE;
close $fh;
print "Wrote to  $filename.\n";

You are reading this post on Joel G Mathew’s tech blog. Joel's personal blog is the Eyrie, hosted here.