On 8/17/05, Paul Johnson <[EMAIL PROTECTED]> wrote: > On Wed, Aug 17, 2005 at 06:26:16PM +0100, marcos rebelo wrote: > > > If I'm not wrong, Changing this lines: > > > > my @col = grep(!/\t/, split(/(\t)/, $line)); > > push(@col, "") if $line =~ /\t$/; > > > > > > by > > > > > > $line .= "\t"; > > my @col; > > my $lastIndex = 0; > > foreach my $actualIndex (0..length($line)) { > > if (substr($line, $actualIndex, 1) eq "\t") { > > push(@col, substr($line, $lastIndex, > > $actualIndex - $lastIndex)); > > $lastIndex = $actualIndex+1; > > } > > } > > > > give me 10% faster code. > > > > > > Is it possible to do faster? > > Probably. > > my @col = split /\t/, $line, -1; > > is much clearer anyway. > > perldoc -f split > > -- > Paul Johnson - [EMAIL PROTECTED] > http://www.pjcj.net >
really my @col = split /\t/, $line, -1; is clearer and even faster. I'm passing one subroutine from 50 sec to 7 sec, really any small inprovement is nice. thanks all Marcos -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>