#!/usr/bin/perl use warnings; use strict; my $string = '123456'; $string .= "\x1c"; # or chr 0x1c printf '%02x ', ord $_, ' ' for split //, $string; print "\n";