I have this code to create a list of .txt files inside of a dir, and print it in 2 columns in a output file; so I just want to avoid the new line (\n) after of the last file
#!/usr/bin/perl -w
use strict;
use Getopt::Long;
#Variables
my ($dir_path, $outputfile);
GetOptions (
            'dir=s'      =>\$dir_path,
            'list=s'      =>\$outputfile
            );
opendir (DIR, $dir_path) or die $!;
open LIST, '>', $outputfile, or die "can´t open $outputfile file";
while (my $files=readdir(DIR)) {
    chomp $files;
    if ($files =~ m/\.txt$/g) {
        print LIST "$files\t$files\n";
    }
    else {
        next;
    }
}
closedir DIR;
close LIST;
exit;
it print:
file_1.txt file_1.txt
file_2.txt file_2.txt
file_3.txt file_3.txt
file_Last.txt file_Last.txt
NEW_LINE (\n)
and I just want to avoid print the las NEW LINE after of the last file !!!:
file_1.txt file_1.txt
file_2.txt file_2.txt
file_3.txt file_3.txt
file_Last.txt file_Last.txt