in reply to Re: how to find differences between two huge files
in thread how to find differences between two huge files

Instead of these:
m[^ ( [^|]+ ) \| ]x and $current{ $1 } = $_ while <CURRENT>; ... if( m[^ ( [^|]+ ) \| ]x and exists $current{ $1 } ) {
you could do:
(my $e=index($_,"|"))>0 and $current{substr($_,0,$e)}=$_ while <CURREN +T>; ... if((my $e=index($_,"|"))>0 and exists $current{substr($_,0,$e)) {
It's a bit more typing, but depending on the string lengths and quantities involved, it might end up running a little faster (and the extra letters spelling out the function names may help to provide a bit of explanation about what's actually going on).

(I guess the scope of the first temporary "$e" will be wider than necessary, given the absence of curly brackets for that "while" loop, but just a little more typing would fix that as well.)

Replies are listed 'Best First'.
Re^3: how to find differences between two huge files
by BrowserUk (Patriarch) on Jan 25, 2008 at 11:44 UTC

    I don't see why you want to replace the regex? It's concise, fast and does exactly what I need it to do.

    Is it the form of the regex itself? Noone would look twice if it were m[" ( [^"]+ ) "]x, and it's exactly the same operation.


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.