use strict; use warnings; use File::Copy; my @files = qw(Ardbeg.txt Bowmore.txt Bruichladdich.txt Bunnahabhain.txt Caol_Ila.txt Kilchoman.txt Lagavulin.txt Laphroaig.txt Port_Charlotte.txt); my $given_path = '/tmp/allfiles'; my $some_otherpath = '/tmp/nonemptyfiles'; for my $f (@files) { if( -f "$given_path/$f" && ! -z "$given_path/$f" ) { copy( "$given_path/$f", "$some_otherpath/$f" ) } }