----- Original Message ----- From: <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Monday, March 06, 2006 10:06 PM
Subject: regexp vs substr for string capture?


#--------------------------------------------------------------------------------------------------------
 use strict;
 use warnings;

 use Benchmark qw(timethese cmpthese);

 my $data_line = '    <TD class=xc01>Wanted data goes here</TD>';
 my $tag;

 my $r = timethese( 1_000_000, {

    'new way' => sub {
        $data_line =~ />([^\<]+)\</;
        $tag = $1;
    },

    'old way' => sub {
        $tag = substr( $data_line, 19, -5 );
    },

 } );

 cmpthese( $r );
#---------------------------------------------------------------------------------------------------------


I have not Benchmark module instaled. Please can you test this?

    'new way' => sub {
        $data_line = $tag;
        $tag =~ s/<.+?>//g;
    },

Petr Vileta, Czech republic
(My server reject all messages from Yahoo and Hotmail. Send me your mail from another non-spammer site please.)


_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to