Thank you very much for your detailed input!
In my case, there's not much more going on in the code and efficiency is not really a concern, as I'm working with very short lists of no more than maybe 5 elements or so. But I'd like to do things as "correctly" as possible which is why I was indeed looking to exit the lookup on the first match. Using first comes really in handy here, I'm glad that I asked as I obviously have a lot to learn about Perl. I'll be sure to read more about all these functions (thanks for the links!)/
I'm calling split since it's such a short string anyway that it just seems more than enough. Plus, I'm intentionally restricting myself to the core modules to learn Perl more properly before I go out using other solutions, if that makes sense. At least for now, of course, as I'm not really making anything significant or complex, just small scripts for my own use.
Just to clarify, this question refers to a simple script that can extract URL parameters out of a text file, with an option to provide the components to select from each match, like a specialized type of grep on the command line just for URLs:
xurl --select domain,route file1 file2 ... xurl --select proto,credentials file1 file2 ...
I'm taking my time to refine this script with better language features and cleaning it up, and this sort of questions come up from time to time.
Thanks again!
In reply to Re^2: Question about loops and breaking out of them properly
by unmatched
in thread Question about loops and breaking out of them properly
by unmatched
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |