Edward WIJAYA wrote:
Dear friends,

Hello,

After a couple of months dwelling into Perl scripting especially in manipulating strings, I found myself resorting to use "substr" function a lot.

I had a feeling that the most of the "substr" function can be replaced with regexp in any cases. For example the simple code below. I wonder how would masters redo this function with pure reqexp approach.

I don't know if I am a master but I wouldn't use a regular expression.

sub hamming_distance_string { ( $_[0] ^ $_[1] ) =~ tr/\0// }


However, if you really want to use a regular expression (although it won't be as efficient.)


sub hamming_distance_string { () = ( $_[0] ^ $_[1] ) =~ /\0/g }




John -- use Perl; program fulfillment

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to