$ perl -le' my $input_string = "test"; print substr( $_, 2 ), substr $_, 0, 2 for unpack( "H*", $input_string ) =~ /.{1,4}/g; ' 6574 7473