for my $file ( glob( "$somedir/example*.txt" ) ) { #### for my $file ( grep m#/example(\d+\.)+txt$#, glob( "$somedir/example*.txt" ) ) {