Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re^4: How to remove everything after last occurrence of a string?

by GrandFather (Saint)
on Jun 07, 2022 at 23:45 UTC ( [id://11144499]=note: print w/replies, xml ) Need Help??


in reply to Re^3: How to remove everything after last occurrence of a string?
in thread How to remove everything after last occurrence of a string?

It comes down to choosing the right tool for the task at hand. That is an art in itself. Often a regex is the right tool to solve a tricky matching problem. Sometimes something like index is the tool to use for a simple matching problem or where speed is critical. My main point is that raw execution speed should not be the first consideration when choosing tools to solve a problem. Demonstrable correctness and maintainability should come first and often go hand in hand. At this point the discussion doesn't have much to do with the OP or the specific implementation of any reply.

My reply was addressing what could be seen as a "speed first" approach to coding being advocated by kcott's reply. Ken is an experienced coder so he can skip a few iterations ahead to get a solution that is both clean and quick. That is something that comes with experience, often bitter, so I thought a heads up for the less experienced was in order.

Optimising for fewest key strokes only makes sense transmitting to Pluto or beyond

Replies are listed 'Best First'.
Re^5: How to remove everything after last occurrence of a string?
by eyepopslikeamosquito (Archbishop) on Jun 08, 2022 at 09:49 UTC

    Demonstrable correctness and maintainability should come first ... My reply was addressing what could be seen as a "speed first" approach to coding being advocated

    Strongly agree! See: on Code Optimization

    Sadly, there seems to have been an increase lately in monks asking for faster code without explaining why speed matters for their problem and without providing a benchmark. Some reacted appallingly on being given your well-meaning advice, one even deleting all his content and leaving the monastery in a huff.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (3)
As of 2024-03-29 07:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found