# first define our hash (just the once not for every bloody line!!!!!! :o) my %opcodes = ( blah ); open (SOURCE, "z80code.o") or die "Couldn't open destination file."; while () { print DEST encode($_)."\n"; } sub encode{ # blah }