open (fp,$ARGV[0]) || die ("Can't open $ARGV[0]! Exiting."); while () { if (!m/^\s*\/\//) #Ignore commented lines { s/\/\/.*//g; while (m/([A-Za-z0-9_\.\:]+)/g) { if (exists $my_replacement{$1}) { s/$1/$my_replacement{$1}/; } } } print $_; }