Generating a list of virtualmin public folders for backup

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

#!/usr/bin/perl
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";