What should the code do? If the version string is
5.14.0, you are replacing the build value(?) with an
undef. You should rather test for
defined. But, if your intention is to supply undefs for missing information at the end of the string, you can delete most of the code: for 5.14.0, revision is already
undef.