I don't know if split is or isn't optimized; I just have a story related to split to share.
In our code library, we have a function named rand_split, which looks like this:
sub rand_split {
my ($sep, $string) = @_;
my ($element, $char, $pos, $end, @array);
$end = length($string);
$element = "";
for ($pos = 0; $pos < $end; $pos++) {
$char = substr($string, $pos, 1);
if ($char eq $sep) {
push (@array, $element);
$element = "";
} else {
$element = $element . $char;
}
}
push (@array, $element);
return (@array);
}
rand_split was written by a guy named Rand a couple of programmer generations ago. We don't know why he reimplimented it; We don't know a lot of things about it. However, another programmer from around that generation claimed that "If he did it, there must have been a reason." It's not like he didn't know split didn't exist, meaning he purposefully reinvented a wheel. As nearly as we can tell, it walks like split and talks like split; Therefore, it is split. It's used in one script these days, and probably zero in the very near future, but I think we've kept it around mainly for gag value, giving every new generation of programmer something to wonder about.
In reply to Re: is split optimized?
by bs
in thread is split optimized?
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |