Edward Wijaya wrote:
Seems that John's regex approaches are (much) faster:
Rate HD_string HD_jkrahn2 HD_jkrahn1
HD_string 203251/s -- -18% -76%
HD_jkrahn2 247033/s22% -- -71%
HD_jkrahn1 848840/s 318% 244% --
[snip]
sub h
Seems that John's regex approaches are (much) faster:
Rate HD_string HD_jkrahn2 HD_jkrahn1
HD_string 203251/s -- -18% -76%
HD_jkrahn2 247033/s22% -- -71%
HD_jkrahn1 848840/s 318% 244% --
__BEGIN__
#!/usr/bin/perl -w
us
From: "John W. Krahn" <[EMAIL PROTECTED]>
> Peter Scott wrote:
> > In article <[EMAIL PROTECTED]>,
> > [EMAIL PROTECTED] (Edward Wijaya) writes:
> >
> >>BTW, can you explain what's the difference between these two?
> >>
> >>>sub hamming_distance_string { ( $_[0] ^ $_[1] ) =~ tr/\0// }
> >
> > In
Peter Scott wrote:
In article <[EMAIL PROTECTED]>,
[EMAIL PROTECTED] (Edward Wijaya) writes:
BTW, can you explain what's the difference between these two?
sub hamming_distance_string { ( $_[0] ^ $_[1] ) =~ tr/\0// }
In a scalar context, tr/// returns the count of the number of
characters seen.
sub
In article <[EMAIL PROTECTED]>,
[EMAIL PROTECTED] (Edward Wijaya) writes:
>BTW, can you explain what's the difference between these two?
>
>>
>> sub hamming_distance_string { ( $_[0] ^ $_[1] ) =~ tr/\0// }
In a scalar context, tr/// returns the count of the number of
characters seen.
>> sub hamm
Thanks so much for the reply John,
On Mon, 03 Jan 2005 04:07:05 -0800, John W. Krahn <[EMAIL PROTECTED]> wrote:
I don't know if I am a master but I wouldn't use a regular expression.
In my eyes, you certainly is a master!
BTW, can you explain what's the difference between these two?
sub hamming_di
From: "Octavian Rasnita" <[EMAIL PROTECTED]>
> If you can use substr(), use it, because it works much faster than
> regexp.
>
> Teddy
Nope. One substr() will of course be quicker than one regexp
application, but a loop containing substr() will most of the time
slower than a single regexp.
You
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 ex
If you can use substr(), use it, because it works much faster than regexp.
Teddy
- Original Message -
From: "Edward WIJAYA" <[EMAIL PROTECTED]>
To:
Sent: Sunday, January 02, 2005 5:08 PM
Subject: Choosing between Regexp and Substr
> Dear friends,
>
> After a
Dear friends,
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.
10 matches
Mail list logo