$origfile = shift; @chunks = split(/\./, $origfile); $ext = pop @chunks; $filename = join("", @chunks, ".$ext"); rename $origfile, $filename;