sub getchar_unpack { my ($string, $index) = @_; return unless $index >= 0 and $index < length($string); return chr( (unpack 'C*', $string)[$index] ); } sub getchar_split { my ($string, $index) = @_; return unless $index >= 0 and $index < length($string); return ( (split //, $string)[$index] ); } sub getchar_loop { my ($string, $index) = @_; return unless $index >= 0 and $index < length($string); $string = reverse $string; my $c; $c = chop $string until $index-- == 0; return $c; }