in reply to Making this script process 56,000 lines 5 times faster
You didn't anchor your regexes like in the grep example, they only need to match at the start /^0\.0\.0\.0/ , the other regex to exclude comments is obsolet then.
And use chomp not an (again unachored) regex to strip newlines.
I might also try to use a while (my $line = <$in> ){...} loop instead of for , but you need to do something like open my $in ,"<", \$got; beforehand.
Perl might still be slower, because it needs more time for start up and compiling*.
(all code untested)
PS: there are more advanced tricks possible in this specific case, but you want to learn Perl and I don't wanna exaggerate it.
the substitution $_ =~ s/0\.0\.0\.0 //; doesn't make sense if you match the remaining of the line right away
if (/^\Q0.0.0.0\E (.*)$/) { print "<<<$1>>>"; }
Cheers Rolf
(addicted to the Perl Programming Language and ☆☆☆☆ :)
Wikisyntax for the Monastery
*) especially LWP::Simple! For a fair comparison try to pipe in curl.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Making this script process 56,000 lines 5 times faster
by kris004 (Initiate) on Mar 22, 2018 at 04:08 UTC |