Open vsespb opened 11 years ago
You are right... these are not equivalent. But I wrote that code for accomplishing the purpose which get a module path from a module name. Do you have a better idea ?
I think for benchmarking need to compare functions which return same result for same arguments, so need compare 'y//' with 's//' code only if 's//' replaces one character.
It's not really important if those functions called with some useful arguments and do real job.
If you want useful code example - you can, for example, replace '/' with '\' in filenames to convern Unix path to Windows path.
Or you can just replace s{::}{/}g with s{:}{/}g. It will perform same way as tr// - replace only one character (filenames with two slashes are still valid)
https://github.com/azumakuniyuki/perl-benchmark-collection/blob/master/operator/s-vs-y.pl#L16
is not same as
'y' replaces each ':' with '/', while 's' replaces '::' with one character '/'
http://perldoc.perl.org/functions/y.html