sub chr_at { my ($data, $skip) = @_; --$skip; $data =~ /^.{$skip}(.)/; $1; } for (1..4) { print chr_at("abcd", $_) . "\n"; }