Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

Re: Script far too slow with large files - wisdom needed!

by RichardK (Parson)
on Jan 21, 2016 at 17:53 UTC ( #1153308=note: print w/replies, xml ) Need Help??

in reply to Script far too slow with large files - wisdom needed!

It might improve things a bit if you rearrange your if statements, you don't need to check ($A + $B == 2...) for each line of the input file, as you know that $B can only change when you've matched RTINSECONDS so you could do this instead :-

if ($line =~ /TITLE=(.*)/) { $title=$1; } elsif ($line =~ /RTINSECONDS=(.*)/) { $RT=$1; if ($title && grep {$_ eq $TI} @IDS) { $IDrtPairs{$TI}=$RT; $title = undef; } }

As already mentioned it will be better to use a hash, so you should do that too :)

The example input data looks like TITLE & RTINSECONDS are always at the beginning of the line so you could anchor your regexs too, so it can reject non matching lines quicker. i.e. /^TITLE=(.*)/

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1153308]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (6)
As of 2020-05-29 18:06 GMT
Find Nodes?
    Voting Booth?
    If programming languages were movie genres, Perl would be:

    Results (170 votes). Check out past polls.