#!/usr/bin/ruby print "hexadecimal = " hex = gets.chomp if ( hex =~ /[^0-9A-Fa-f]./ ) print "not a hexiadecimal number\n" exit else puts hex.hex end