http://www.perlmonks.org?node_id=699433


in reply to Re: Help with parsing a string
in thread Help with parsing a string

If you lines contain other text besides the hex numbers, you can restrict the space removal to just between the hex numbers with:
$line =~ s{\b([a-f\d]{2})\s+(?=[a-f\d]{2}\b)}{$1}gi;