in reply to Get char in string
Assuming you mean get the X numbered character from the string, you could do...
sub chr_at { my ($data, $skip) = @_; --$skip; $data =~ /^.{$skip}(.)/; $1; } for (1..4) { print chr_at("abcd", $_) . "\n"; }
...but I wouldn't be supprised if the substr() version is faster.
|
|---|