#!/usr/bin/perl # https://perlmonks.org/?node_id=1218012 use strict; use warnings; my $dirname = 'some/test'; my $outputfile = 'some.output.name'; local @ARGV = grep -f, glob "$dirname/*"; @ARGV or die "no files in $dirname"; open my $out, '>', $outputfile or die "$! opening $outputfile"; print $out $_ while <>; close $out;