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.
In reply to Re: Get char in string
by nevyn
in thread Get char in string
by PerlLoveMe
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |