Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

How come my converted awk/sed/sh script runs more slowly in Perl?

awk converted Perl Script SED sh
0
Posted

How come my converted awk/sed/sh script runs more slowly in Perl?

0

The natural way to program in those languages may not make for the fastest Perl code. Notably, the awk-to-perl translator produces sub-optimal code; see the a2p man page for tweaks you can make. Two of Perl’s strongest points are its associative arrays and its regular expressions. They can dramatically speed up your code when applied properly. Recasting your code to use them can help a lot. How complex are your regexps? Deeply nested sub-expressions with {n,m} or *operators can take a very long time to compute. Don’t use ()’s unless you really need them. Anchor your string to the front if you can. Something like this: next unless /^.*%.

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123