@to_be_written = grep { split(/_/)[0] <= $today } @busdir; #### foreach (@to_be_written) { if ( split(/_/)[0] <= $today ) { do_magic_file_copy_thing_here( $_ ); # $_ is the filename of interest } }