my $start = index($@, 'HASH(0x') + 7; my $end = index($@, ')', $start); my $hex = substr($@, $start, $end-$start);