in reply to Re: Process large text data in array
in thread Process large text data in array

hdb your codes are excellent!! The speed reduced to only 21sec to complete. My previous sub codes were rather old and previous data format may contain more than 1 delimiter characters. But all my current data format will have "safe characters" encoding before storing. So I guess it is safe to use your code for my purpose use.

If it is not too trouble, maybe could you help me improve the reversal of line2rec? Or that is the simplest and faster it can goes?

#---------------------------------------------------# # REC2LINE #---------------------------------------------------# sub rec2line { my (%trec) = @_; my ($newline) = ""; my ($line); foreach $line (keys %trec) { if ($newline ne "") { $newline .= "|"; } $newline .= "$line=$trec{$line}"; } # end foreach return ("$newline"); } # end sub

Thanks again.

Replies are listed 'Best First'.
Re^3: Process large text data in array
by hdb (Monsignor) on Mar 10, 2015 at 15:05 UTC

    That is what join is for:

    $newline = join "|", map { "$_=$trec{$_}" } keys %trec;