while (defined ($img=readdir DH)){ $img=~m/^(.*)\.(.*)\.(.*)/g; $newname="$1.$3";